Re: loading data from ascii file
- From: Peter Boettcher <boettcher@xxxxxxxxxx>
- Date: Wed, 31 Aug 2005 09:30:13 -0400
Felix <feboll@xxxxxx> writes:
> Hi!
> I have to read data from an ascii file which is several GB large.
> lines represent individual datapoints. I would like to read only some
> lines, the linenumbers are stored in a matlab vector. is there any
> possibilty to this without loading the whole array (which is too)
> big.
Random access in an ascii file is very difficult, if not impossible,
as the program can never know how many linefeeds exist between any two
byte offsets, without reading them all.
I would suggest converting the whole mess to a binary file, ONCE.
Seeking around a binary file is straightforward, and faster too.
I would use a block-processing approach to converting the file. Read
one line, or a bunch of lines (100? 1000?) at once, using fscanf or
fgetl. Convert, then fwrite the output to your output file. That
way, only a small amount of the file is in memory at any time.
Then, for random access, fseek to the byte offset you need. (row
number x row size x element size).
--
Peter Boettcher <boettcher@xxxxxxxxxx>
MIT Lincoln Laboratory
MATLAB FAQ: http://www.mit.edu/~pwb/cssm/
.
- Follow-Ups:
- Re: loading data from ascii file
- From: Felix
- Re: loading data from ascii file
- References:
- loading data from ascii file
- From: Felix
- loading data from ascii file
- Prev by Date: Re: Matlab Beginner fundamental issues
- Next by Date: 热电偶
- Previous by thread: Re: loading data from ascii file
- Next by thread: Re: loading data from ascii file
- Index(es):
Relevant Pages
|
Loading