How can I estimate the time required by textscan and the size of the output?
古いコメントを表示
Hello,
I am running Matlab 2013b on Windows 7. I have 8 GB RAM memory and a I set the swap file to 20 GB.
I am trying to read a relatively large txt file that is tab separated. The size of the file on the hard disk is a little over 2 GB. There are 6 columns and approx. 64 million rows in the file. The entries are mixed (strings and numbers with some missing values).
At this point I am using:
textscan(fid,repmat('%s',1,6),'delimiter','\t');
It is running for about 4 hours now using about 6.5 GB RAM.
1. I would like to know how can I estimate the time it takes to read the file and the size of the output.
2. After it is done I would like to extract the numerical values from the resulting cell matrix and save that to a .mat file. Any idea how long that would take?
3. Is there any better way of doing this? If I could extract from the file a matrix with the numerical values only (setting everything else to NaN) it would be great.
Thanks!
3 件のコメント
per isakson
2014 年 7 月 31 日
編集済み: per isakson
2014 年 7 月 31 日
"using about 6.5 GB RAM."   How did get you get this number? I would have thought close to 8GB.
Alexandru
2014 年 7 月 31 日
per isakson
2014 年 7 月 31 日
編集済み: per isakson
2014 年 7 月 31 日
Strange! Could there be something using memory that the task manager doesn't report on? Is your system 64bit?
採用された回答
その他の回答 (1 件)
dpb
2014 年 7 月 30 日
1 投票
Don't know that there is any metric to predict run time other than testing as it's so dependent upon the machine characteristics, not just size.
Two things I can think of to try --
a) Use the specific format for the data file -- strings for string, numeric for numbers. Skip ('%*s' for example to skip a string field) any fields that aren't mandatory. Use "'collectoutput',true" to gather the various types together. This will bypass a subsequent conversion step.
b) Use the feature of textscan to process the file in pieces -- say 1 to a few MB roughly per pass.
4 件のコメント
Alexandru
2014 年 7 月 31 日
per isakson
2014 年 7 月 31 日
Skipping columns with %*s works regardless of which characters are in the column.
Alexandru
2014 年 7 月 31 日
per isakson
2014 年 7 月 31 日
編集済み: per isakson
2014 年 7 月 31 日
Yes, if it is a reasonable number of different string constants and you know them beforehand.
>> cac = textscan( 'char; 23.1; 16', '%f', 'Delimiter', ';' ...
, 'treatAsEmpty', {'char'} );
>> cac{:}
ans =
NaN
23.1000
16.0000
nan regardless of case is converted to "NaN"
カテゴリ
ヘルプ センター および File Exchange で Large Files and Big Data についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
