Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Find and Replace in huge text file
Message
De
27/09/2005 11:35:53
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01053411
Message ID:
01053475
Vues:
25
Why don't you use fread(), fwrite(). You might have lines over 8192.ie:
#define MAXBUFFER 65536
lhIn = FOPEN(lcFileIn)
lhOut = FCREATE(lcFileOut)
DO WHILE NOT FEOF(m.lhIn )
  fwrite(m.lhOut,strtran(fread(m.lhIn, MAXBUFFER),'AD00','BR77'),MAXBUFFER)
ENDDO
FCLOSE(m.lhIn)
FCLOSE(m.lhOut)
Cetin

>Record length is not fixed, there is emebeded Carriage return within the file, so FPUTS most of times return 8192 bytes but some times it return less if there is carriage return ( in that case I need to add carriage return to the output file if FPUTS does not get 8192 byte to keep same structure).
>Is there any way to know how many bytes did FGETS return with ?
>
>
>>I'm not sure I understand you. What's the max record len in the file?
>>
>>>That works fine, except for the carriage return.
>>>I need to know if FGETS had got 8192 byte (No need for carriage return - use fwrite, or FGETS had less than 8192 byte, so I need to add carriage return FPUTS).
>>>any help on that.
>>>
>>>>You can use LLFF. A sample code (w/o any error handling)
>>>>lhIn = FOPEN(lcFileIn)
>>>>lhOut = FCREATE(lcFileOut)
>>>>DO WHILE NOT FEOF(lhIn )
>>>>  lcLine = FGETS(lhIn,8192)
>>>>  * Processing here
>>>>  = FPUTS(lhOut, lcLine)
>>>>ENDDO
>>>>FCLOSE(lhIn)
>>>>FCLOSE(lhOut)
>>>>
>>>>
Ç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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform