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:
00580854
Views:
17
Hi Andrew,

Yes, this is what I had in mind, but my concern is speed. Would this method be faster, than post-processing, and a little alternative to this method (create chunk strings (say, 10000 recs), then write to file using strtofile, would it be faster or same speed).

>Hi Nadya,
>
>I'd use
>
SET TEXTMERGE TO (filename) NOSHOW
>SET TEXTMERGE ON
>SCAN
>\<<alltrim(field1)>>|^
>\\<<field2>>|^
>... etc
>ENDSCAN
>SET TEXTMERGE TO
>You could even do a FOR I = 1 to FCOUNT() and then use TRAN(EVAL(FIELD(I))) in the expression:
>
>
SET TEXTMERGE TO (filename) NOSHOW
>SET TEXTMERGE ON
>local lnFirstRec
>go top
>lnFirstRec = recno()  && allows for indexes where recno()=1 is not first record
>SCAN
>for i = 1 to fcount()
>  do case
>    case i = 1 and recno() # lnFirstRec
>      \<<alltrim(transform(eval(field(i))))>>|^
>    case i = fcount()
>      \\<<alltrim(transform(eval(field(i))))>>
>    otherwise
>      \\<<alltrim(transform(eval(field(i))))>>|^
>  endcase
>endfor
>ENDSCAN
>SET TEXTMERGE TO
>
>HTH
>
>Cheers,
>
>Andrew
>
>>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
Reply
Map
View

Click here to load this message in the networking platform