Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Text Files
Message
From
30/09/2000 04:17:17
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
29/09/2000 15:37:57
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00422628
Message ID:
00423049
Views:
34
>>PS. You rarely need to resort to low level file I/O, using FOPEN(), to import a text file into a table. Low level File I/O is also probably the slowest way to process the file. On a PC with a lot of RAM, you may also find that your (millions) of records can be imported straight into a text variable using FILETOSTR() and then popped into an array using ALINES().
>
>Ok, tried the above and I get an error saying my computer doesn't have enough memory to complete the operation. These are massive .txt files. Is there a way to just read one line or a chunk of lines at a time from them?
>
>Thanks!


Amanda,
You cannot use alines() with millions lines. 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
Ç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