Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find and Replace in huge text file
Message
From
28/09/2005 04:40:33
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
28/09/2005 04:31:52
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01053411
Message ID:
01053785
Views:
25
>>>>FYI with Greg's modified version 26Mb file is processed in 1.3 secs (pure VFP code).
>>>>Cetin
>>>>
>>>
>>>Sinned that it is wrong :)
>>
>>What is wrong? Timing or code? Timing might be. On my box that's what I got, yours might be more or less.
>>Cetin
>
>the code.
>
>post your code test. Thanks
TEXT to m.lcMyText noshow
0AD0AD0012123AD0012312AD0012341AD00AD0010123
12AD0012123AD0012312AD0012341AD00AD0010123AD0012123AD0012312AD0012341AD00AD001
ENDTEXT
lcTemp1 = Sys(2015)+'.txt'
lcTemp2 = Sys(2015)+'.txt'
Strtofile(m.lcMytext,m.lcTemp1)

*!*	lcTemp1 = 'bigfile.txt' && 138Mb
*!*	lcTemp1 = 'bigfile.tx2' && 26Mb
*!*	lcTemp2 = 'bigfile.ou2'

#Define MAXBUFFER 5

lhIn = Fopen(m.lcTemp1)
lhOut = Fcreate(m.lcTemp2)
Set Step On 
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)
Modify Comm (m.lcTemp2)
Erase (m.lcTemp1)
Erase (m.lcTemp2)
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