Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find and Replace in huge text file
Message
From
28/09/2005 03:52:40
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
27/09/2005 17:39:51
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01053411
Message ID:
01053762
Views:
26
>Try this (modified from Cetin code) for testing if the replaced string is being split during FREADs:
>
>
>#DEFINE MAXBUFFER 65536
>lhIn = FOPEN(lcFileIn)
>lhOut = FCREATE(lcFileOut)
>DO WHILE NOT FEOF(m.lhIn )
> lcBuffer = FREAD(m.lhIn, MAXBUFFER)
> DO CASE
> CASE RIGHT(lcBuffer,3) = 'AD0'
> FSEEK(m.lhIn, -3, 1)
> lcBuffer = LEFT(lcBuffer,LEN(lcBuffer)-3)
> CASE RIGHT(lcBuffer,2) = 'AD'
> FSEEK(m.lhIn, -2, 1)
> lcBuffer = LEFT(lcBuffer,LEN(lcBuffer)-2)
> CASE RIGHT(lcBuffer,1) = 'A'
> FSEEK(m.lhIn, -1, 1)
> lcBuffer = LEFT(lcBuffer,LEN(lcBuffer)-1)
> ENDCASE
> FWRITE(m.lhOut,STRTRAN(lcBuffer,'AD00','BR77'),MAXBUFFER)
>ENDDO
>FCLOSE(m.lhIn)
>FCLOSE(m.lhOut)

I didn't understand what Fabio meant either. Your code is nicer and faster than mine:) It processed a 138+Mb file in 14 secs on my box (Athlon 2500+,512Mb onboard 64Mbshared mem VGA).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform