Info
This question is closed. Reopen it to edit or answer.
How to read a text file where the data are merged to the first headline title
1 view (last 30 days)
Show older comments
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 Comments
Jeremy Hughes
on 13 Nov 2020
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?
Answers (1)
Cris LaPierre
on 13 Nov 2020
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 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!