Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Text Files
Message
 
 
To
11/10/2000 15:13:22
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00422628
Message ID:
00428038
Views:
24
Amanda,
With regard to large files - low level file I/O using FOPEN(), FGETS(), etc. is actually faster where you only want a subset of the text file being processed. The smaller the subset the bigger the perfornamnce gain (when compared with CREATEing a structure and APPENDing).

However once you get past using about 50% of your data, then there is no (or very little) benefit in using low level file I/O. If all of the data is required (in a large file) then the performance gain swings in favour of APPENDing into a structure. In fact if you APPEND into a structure then you gain by having all of the usual data manipulation techniques that VFP offers - why else would you want to use VFP. Also you cannot BROWSE using low level file I/O, from personal experience I have found that many problems were easily solved because I 'looked' at the data. In addition you do not need to concern yourself with FGETS() work arounds ???

One last point - the (probable) reason that Cetin's solution is stopping after the first line is the embedded CHR(0)'s and CHR(255)'s in your source file. I pointed these out to you in a private e-mail, I'm guessing that you either did not get it, or chose to ignore it?

And finally it now looks like Cetin is also recommending the approach that I suggested at the very beginning!
Houston.

>>You could use lowlevel I/O and it is not 'the slowest way' IMHO. fgets() would read line by line (fgets have bugs depending on size of one line different per version though - SP3 8192 earlier 255. If you search for fgets() or SafeGetLine here in threads you'd find code for a workaround). Anyway there is nonLowLevel approaches (I would probably choose for the task).
>>Create a data structure with all char type fields. Up to real fields use 254 as padders.
>>Append from myText.txt type SDF
>>Then modify structure to drop unwanted parts.
>>ie:
>>pos 1 - 307 chunk
>>pos 308-310 field1
>>pos 311-500 chunk
>>pos 501-505 field2
>>
>>create table myTempTable ;
>> (chunk1 c(254), chunk2 c(307-254),field1 c(3), chunk3 c(500-310),field2 c(5))
>>append from mytext.txt type SDF
>>modi struc
>>
>>Cetin
>
>I found your GetSafeLine function and it works for what I need. Except, in these last moments of sanity, I can't get it to go past the first record of the text file. It reads the first record, puts it into the table, then quits. How do I get it to run thru all 100,000+ records?
>
>Thanks!
censored.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform