load very large data file in 32bit matlab 2013 and windows 7 32bit
1 回表示 (過去 30 日間)
古いコメントを表示
Hi,
i have a very large data file (.txt), 15 coloumns and several rows. (600MB). figures are plotted successfully but have to enlarge the cache memory. is there any way to transform this file to other format so that it can be read quickly and to reduce size . e.g .mat etc,
thanks
0 件のコメント
回答 (1 件)
Walter Roberson
2015 年 12 月 28 日
Generally speaking, you can use
fid_in = fopen('YourInput.txt', 'rt');
fid_out = fopen('BinaryVersionOfTxt.dat', 'w'); %no 't'
while true
inputline = fgetl(fid_in);
if ~ischar(input_line); break; end %end of file
input_num = sscanf(inputline, '%f');
fwrite(fid_out, input_num(:), 'double');
end
fclose(fid_in);
fclose(fid_out);
BinaryVersionOfTxt.dat will now be a binary data file of doubles, with the values saved reading across in row order from the input file. This code will handle any number of inputs on each line and does not put in any kind of end-of-row marker, so be careful about interpreting the file.
If the values are integer then you can reduce storage by changing the program slightly.
You would do the above conversion once and then you can read the binary file any number of times.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Import and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!