From: Gerda Edelman on
I have a problem concerning a large ascii file (1.2 GB), which looks like this:
29 lines of text data
512x640 pixelvalues of a frame
5 lines of text data
512x640 pixelvalues of a frame
5 lines of text data
512x640 pixelvalues of a frame
5 lines of text data
512x640 pixelvalues of a frame
etc.

If I use textscan to read this file my laptop runs out of memory. Using dlmread it goes fine for the first frames, but every next frame it takes longer to be read. I tried some other things, but mostly this resulted in memory problems. Does anybody know a resolution for this, which uses less memory?

Regards, Gerda
From: us on
"Gerda Edelman" <gerdaedelman(a)yahoo.de> wrote in message <hqk2fg$bht$1(a)fred.mathworks.com>...
> I have a problem concerning a large ascii file (1.2 GB), which looks like this:
> 29 lines of text data
> 512x640 pixelvalues of a frame
> 5 lines of text data
> 512x640 pixelvalues of a frame
> 5 lines of text data
> 512x640 pixelvalues of a frame
> 5 lines of text data
> 512x640 pixelvalues of a frame
> etc.
>
> If I use textscan to read this file my laptop runs out of memory. Using dlmread it goes fine for the first frames, but every next frame it takes longer to be read. I tried some other things, but mostly this resulted in memory problems. Does anybody know a resolution for this, which uses less memory?
>
> Regards, Gerda

a hint:
- low level io functions...
- memory mapping the file...

help fopen;
help fseek;
help fread;
help fclose;
help memmapfile;

us
From: Rune Allnor on
On 20 apr, 13:17, "Gerda Edelman" <gerdaedel...(a)yahoo.de> wrote:
> I have a problem concerning a large ascii file (1.2 GB), which looks like this:
> 29 lines of text data
> 512x640 pixelvalues of a frame
> 5 lines of text data
> 512x640 pixelvalues of a frame
> 5 lines of text data
> 512x640 pixelvalues of a frame
> 5 lines of text data
> 512x640 pixelvalues of a frame
> etc.
>
> If I use textscan to read this file my laptop runs out of memory. Using dlmread it goes fine for the first frames, but every next frame it takes longer to be read. I tried some other things, but mostly this resulted in memory problems. Does anybody know a resolution for this, which uses less memory?

Read only as much of the data that you need. This might mean
that you have to write your own parser, but that's not too hard
with the indicated file format.

Rune