How to read only text from a big data?
2 次查看(过去 30 天)
显示 更早的评论
I have a huge data file (.txt) with some text and numeric data. It is organized as follows:
Text1 ....
Numeric data (m1xn1)
Text2
Numeric data (m2xn2)
Text3
Numeric Data (m3xn3).....
so on...
I just want to read the data file and display Text1, Text2, Text3 etc . on the command window. How can do that? I tried the following code which read only the first line. Is it possible to modify the code to read all the text line by line? All these text has 'Scan' in it. So may be by searching for lines with 'Scan' and display in the command window. I dont know how to code this.
file = 'C:\Users\Documents\21072016_Exp_A.txt';
[fid, message] = fopen(file,'rt');
tline = fgets(fid);
disp(tline)
fclose(fid);
2 个评论
per isakson
2017-9-18
编辑:per isakson
2017-9-18
How large is the file compared to the primary memory?
采纳的回答
Walter Roberson
2017-9-18
S = fileread(file);
S = regexp(S, '^\s*[+0123456789-].*$','match','lineanchors', 'dotexceptnewline') ;
fprintf('%s\n', S{:}) ;
5 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Data Preparation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!