Info
此问题已关闭。 请重新打开它进行编辑或回答。
How to read a text file where the data are merged to the first headline title
2 次查看(过去 30 天)
显示 更早的评论
Hi
I am trying to read a text file where where the first data are merged to the headline title, and this title varies between the data. The data start from 1 right after D2O, but title does not always end with D2O.
You can see that the data should be in 4 different columns too
I am looking forward to your help
Thanks in advance :)
3 个评论
Jeremy Hughes
2020-11-13
Is that "D","201" - or - "D20","1" ... or something else. There's no easy way to break that up programatically.
There are also two other "1" characters on that first line.
I think this is a difficult file to read generically. You may have to modify the file (and I really hate suggesting anyone modify files) and try some of the standard tools like readtable.
Where does the file come from? If you can fix the source of the file that would be easier maybe?
回答(1 个)
Cris LaPierre
2020-11-13
Random thought to try. If this is always the format (in particular, the first column is just row number), then try readmatrix or readtable. They will not be able to interpret the very first value, but if that is always 1, you can just add that later.
I made up a dummy data file based on what you showed.
d = readmatrix("ascii-spec.txt")
d(1,1) = 1
%% Now with readtable
d2 = readtable("ascii-spec.txt")
d2.Var1(1) = 1
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!