You didn't say how much physical memory is in your system.
Matlab provides ways to handle large text files, Large Files and Big Data, but forget that for a moment. It's not a free lunch. " (e.g., 10, 100 ,200...)" Does that mean positive whole numbers only? If so, do you know the maximum value of the three first columns, respectively?
"When I load this data" What exactly did you do?
The three first columns will take 4.8GB to store as double.
>> 200*1e6*3*8/1e9
ans =
4.8
But do you need to use double?
Simplest first, convert the three first columns to double and skip the remaining seven columns. Try
fid = fopen( 'c:\whatever\the_huge_text_file.txt', 'r' );
cac = textscan( fid, '%f%f%f%*f%*f%*f%*f%*f%*f%*f', 'HeaderLines',0 );
fclose( fid );
Or use an alternative formatspec, which is a bit easier to read. It says read the first three columns and skip the rest up til a new-line character.
cac = textscan( num2str([1:10]), '%f%f%f%*[^\n]', 'HeaderLines',0 );
Next step requires input from you on the numbers in the three first columns.
In response to the edited question
To keep the precision of the numbers in the text file you need to use double. I'm positive that
fid = fopen( 'c:\whatever\test42.txt', 'r' );
cac = textscan( fid, '%f%f%f%*f%*f%*f%*f%*f%*f%*f', 'CollectOutput',true );
fclose( fid );
will load the three first columns without problems (on your system).
0 Comments
Sign in to comment.