Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Removing break lines from a .txt file
Message
From
21/02/2007 17:53:29
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
21/02/2007 17:07:27
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01197525
Message ID:
01197812
Views:
18
>Hi Mike,
>
>Interesting approach.

Thanks!

> I know nothing about Regex, but I suspect Regex could also be used to achieve what Moises wants to do.

Same here.

> The down-side to your solution is it wouldn't work for lines longer than 254 characters (I often have to deal with 320 character lines and 3071 character lines).

Yes it does! Maximum # of chars per record 65535, maximum # of field 255, maximum # of chars per field 254. Just add more fields. 13 fields x 254 chars = 3302 bytes.

> The downside to my solution is files larger than 16MB.

VFP is all about cursors. After the data is imported, you can use replace commands to update.

>
>Bruce
>
>>>>The approach I will show you makes a noticeable performance difference even on 15Kb file.
>>>>
>>>>>Files are not larger than 50kb per time
>>>>>
>>>>>Moises
>>>
>>>Mike,
>>>You got me. Now I am very curious. Check Message #1197540. There Moises post a link to the file, but that file contains no header row. But you always could add one :-)
>>
>>Specifications are really a good thing. A sample of the file and a sample of the result is important. I examined the file with hex editor. Every line is terminated with ",LF". There is one row with an extra LF.
>>
>>What should happen to the row with the embedded LF?
>>
>>How is it that code like strtran(lcFileStr,chr(10)+chr(13),"|") is working at all?
>>
>>Anyways, here's my contribution. This will read in the file, terminating at the LFs and dropping them too. Then it will output the file with chr(10)+chr(13). It's not as fast on such a small sample, but it's really simple.
>>
>>
CREATE CURSOR temp (cline c(100))
>>APPEND FROM source.txt TYPE SDF
>>COPY fields cline TO target.txt DELIMITED WITH ""
Previous
Reply
Map
View

Click here to load this message in the networking platform