readtable : set up the multiple lines of variables
15 views (last 30 days)
Show older comments
This is my data. The problem appeared at the following image. From the second column, it does not work.
I commanded,
filename = 'A001.txt';
data = readtable(filename,'NumHeaderLines',0,'VariableNamingRule','preserve');
0 Comments
Accepted Answer
Walter Roberson
on 12 Oct 2021
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/760511/A001.txt';
opt = detectImportOptions(filename, 'VariableNamingRule','preserve');
opt.VariableNamesLine = 1;
data = readtable(filename, opt);
data(1:2,1:10)
3 Comments
Walter Roberson
on 12 Oct 2021
I recognized the structure of the first few lines from a previous discussion where I had solved reading the file, so I checked the previous questions they had posted and found the file.
https://www.mathworks.com/matlabcentral/answers/1468736-how-to-load-txt-file-using-readtable
They attached the file there. You can right click on the file link to get the url, and then copy the url into code.
More Answers (0)
See Also
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!