Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
File into memory
Message
De
16/02/2011 14:10:30
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, États-Unis
 
 
À
16/02/2011 13:53:24
Jossue Vega
Healthcare Partners
New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01500424
Message ID:
01500430
Vues:
74
if has been a while but I am sure that fread() will leave the file pointer ready to get the next xx bytes. The only problem is fread() will stop at the first carriage return and ignore the number of bytes. The docs did not say if fgets() will leave the file pointer at the correct place my I would not be surprised if it didn't. So if that is the case then you will be able to get rid of all the fseek() calls.
h = fopen(yourfile)
do while !feof(h) 
  str =  fread(h,64)
   * process
enddo 
fclose(h) 
>Hello all;
>I wrote a prg that opens a text file, reads each line, parses the line and writes it into another file. the program works fine but it takes to long.
>is there a method that i can accomplish this quicker.
>A file that is about 250,000 lines takes almost 2 hours to process. Below is my prg and a few lines of the data from the input file.
>the program creates a new line after every tilde.
>
>the parameter are the file handles created with a Fopen() and fcreate()
>
>PARAMETERS gnInFile, gnOutFile
>LOCAL lnEnd,lnStrt,lnLoop,lcString
>
>lnEnd = FSEEK(gnInFile,0,2) && end of file
>lnEndLoop = lnEnd + 1
>lnStrt = FSEEK(gnInFile,0) && begining of file
>lnLoop = 0
>lcString = FGETS(gnInFile,64)
>
>FOR lnLoop = 1 TO lnEndLoop
> * lnLoop = FSEEK(gnInFile,0,1)
> WAIT WINDOW "Processing byte " + ALLTRIM(STR(lnLoop)) + " of " + ALLTRIM(STR(lnEnd)) NOWAIT
>
> IF AT('~',lcString,1) > 0
> =FPUTS(gnOutFile,SUBSTR(lcString,1,AT('~',lcString,1)))
> lcString = SUBSTR(lcString,AT('~',lcString,1)+1)
> ELSE
> lcString = lcString + FGETS(gnInFile,64)
> ENDIF
>
> lnLoop = FSEEK(gnInFile,0,1)
> IF lnLoop = lnEnd AND (EMPTY(lcString) OR ISBLANK(lcString))
> EXIT
> ENDIF
>ENDFOR
>
>sample of character in the input file. We must create a new line at every Tilde. ~
>
>ISA*00* *00* *ZZ*341884003 *ZZ*113284753 *110215*1703*U*00401*104605543*0*P*>~GS*HC*341884003*113284753*20110215*1703*104605543*X*004010X098A1~ST*837*0001~BHT*0019*00*1046055430001*20110215*1127*CH~REF*87*004010X098A1~NM1*41*2*INTERACTIVE PAYER NETWORK*****46*341884003~PER*IC*EMDEON ADVANCED CLAIMING*TE*6159323021*EM*CLEPRODUCTIONTEAM@EMDEON.COM~NM1*40*2******46*113284753~HL*1**20*1~NM1*85*2*PRAKASHCHANDRA M. RAO, M.D., P*****XX*1326296039~N3*3130 GRAND CONCOURSE~N4*BRONX*NY*10458~REF*EI*010567880~REF*G5*0001~REF*G2*101439~HL*2*1*22*1~SBR*P**999999******ZZ~NM1*IL*1*FUENTES*JUANUTA****MI*16705189~N3*1770 BRUCKNER BLVD*13B~N4*BRONX*NY*10473~DMG*D8*19400518*F~NM1*PR*2*HERITAGE*****PI*11328~HL*3*2*23*0~PAT*21~NM1*QC*1*FUENTES*JUANITA
>
>Thank you in advance for your time and efforts.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform