robsuttonjr
MIS
I am looking for the fastest method of parsing large binary files. I have to scan the data in the file to figure out the delimeters first as they can be different between files received. Once I know the data and segment delimeters I can parse the data. So far I have tried FOPEN() and FREAD() one character at a time which is pretty slow. I have looked at doing the same type of process FILETOSTR() then scanning through the string 1 character at a time. Once I hit the end of segment delimeter I do something with the resulting string. So the question is has anyone else had to deal with this and what is the best method of doing this in fox? The files can be from 11-30 MB and like I said are binary. Speed is critical as right now I am at about 10 minutes for 11MB file.
In the sample line below from the binary file the * represents the data delimeter and < represents the segment delimeter:
************
ISA*00* *00* *02*UPSN *88*4838483848 *848384*1111*U*11111*122211212*0*P*><GS*IM*UPSN*9466284343*87994939*1111*222*X*443333<ST*444*009888888<B3**000000EA8484897**PP**20070553*1750****PPPP*24444321<C3*USD<ITD*01<N9*18*00003434KV
***********
The end result will be something like this (showing 3 segments truncated):
ISA*00.....<
GS*IM*....<
ST*444*...<
I would have code to handle each segment in steps. The biggest issue is that I need to process these large files very quickly but so far I am at about 10 minutes using FREAD() and a bit less for the FILETOSTR() method.
Regards,
Rob
In the sample line below from the binary file the * represents the data delimeter and < represents the segment delimeter:
************
ISA*00* *00* *02*UPSN *88*4838483848 *848384*1111*U*11111*122211212*0*P*><GS*IM*UPSN*9466284343*87994939*1111*222*X*443333<ST*444*009888888<B3**000000EA8484897**PP**20070553*1750****PPPP*24444321<C3*USD<ITD*01<N9*18*00003434KV
***********
The end result will be something like this (showing 3 segments truncated):
ISA*00.....<
GS*IM*....<
ST*444*...<
I would have code to handle each segment in steps. The biggest issue is that I need to process these large files very quickly but so far I am at about 10 minutes using FREAD() and a bit less for the FILETOSTR() method.
Regards,
Rob