Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best way to create delimited file with non-standard deli
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00580703
Message ID:
00581118
Views:
24
>Hi Nadya,
>
>By all means, do some benchmarking, but my understanding is that opening a LLF (with SET TEXTMERGE TO) and then using LLF output functions (WITH \|\\) is very quick. With VFP 7 you could also SET TEXTMERGE TO MEMVAR in shunks of, say, 10000 (again benchmarking will help here) and then strtofile(, .t.).
>
>Cheers,
>
>Andrew

Thanks again. Cetin provided fll for post-processing and I guess, this is the route, we'll choose. I'm stuck today with lots of other stuff, so I don't know, when I can run these tests... I even don't have time to read UT... :(
>
>>>Hi David,
>>>
>>>If the files are of a reasonably small size, then I'd agree that this is a great way to go. If OTOH they "have ~250 fields and may be huge" then even as few as 100k records blows out to almost 500Mb - My guess is that Fox is going to start paging like crazy on most systems. Writing direct to the disk with LLF or SET TEXT (which is really just LLF wrapped up pretty-like <g>) would work better here IMO. It also saves two sets of I/O (just write rather than write/read/write).
>>
>>Andrew,
>>
>>The problem for us is what to choose. The approach, you demonstrated in other message or post-processing approach, since COPY TO command works very fast and fll, provided by Cetin, works also fast and my manager likes it. (See Remove double quotes FAQ). However, if we decide to go this route, I need another C++ code to remove and replace at once or at least replace char with two chars. Not a big problem, but I don't have C++ Help installed, so it would be some hassle...
>>
>>
>>
>>>Cheers,
>>>
>>>Andrew
>>>
>>>>Nadya,
>>>>
>>>>If you want to use COPY TO, try this:
>>>>
>>>>COPY TO dsstemp.txt TYPE DELIMITED WITH "" WITH CHARACTER "~"
>>>>STRTOFILE(STRTRAN(FILETOSTR('dsstemp.txt'), '~', '|^'),'dsstemp.txt')
>>>>MODI FILE dsstemp.txt
>>>>
>>>>
>>>>No fll needed to transform. The DELIMITED WITH "" stops you from having quotes used to wrap text, and the WITH CHARACTER "~" uses that character instead of comma to separate fields (important since without quotes, embedded commas inside strings would confuse things -- I assume you don't have the ~ character in your text). Then the STRTRAN substitutes your two character for the ~.
>>>>
>>>>>Hi everyone,
>>>>>
>>>>>VFP6.0 SP5
>>>>>
>>>>>I have a requirement to create a text file from our database, where delimiters would be |^ (two symbols) and char data would not have quotes. Files have ~250 fields and may be huge.
>>>>>
>>>>>I'm thinking about two possible approaches:
>>>>>1) Scan the file and process it manually (here is a subquestion: do it through textmerge or create chunk string and put this string into file)
>>>>>
>>>>>2) Use copy to command and process the file afterward (Need some fll to make this replacement).
>>>>>
>>>>>What do you think would be better? Does somebody have a similar experience and some benchmarking?
>>>>>
>>>>>Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform