Error using dlmread (line 147) even though specifying a range that only has numeric values.
3 views (last 30 days)
Show older comments
RC = csvread('D:\School\CMPE215\Project\Matlab\LOG00007.01.csv', 8026, 11, [8026 11 12000 14]);
My CSV has some column headers that are words but the range that I am specifying has only numeric values yet I am still getting an error that it is having trouble reading some values from row 1 even though I am telling it to skip row 1...
Attached is the csv.
I have also tried
RC = csvread('D:\School\CMPE215\Project\Matlab\LOG00007.01.csv', 8026, 11, 'L8026..O12000');
0 Comments
Answers (1)
Walter Roberson
on 31 May 2018
Historically, csvread() and dlmread() could not handle text anywhere in the file. Somewhere around R2014a or so, that changed.
Current versions of csvread() and dlmread() can handle limited text, but only if the text is lines at the top or columns at the left, and only if the user asks for them to be skipped.
csvread() and dlmread() cannot handle text anywhere below or to the right of the section you ask to skip. They handle selecting a data range like your [8026 11 12000 14] request by first reading in all the data below and to the right of the 8026 rows you ask to skip, and the 11 leading columns you ask to skip, and putting it all in a matrix, and then extracting parts of it after that is all done. The undocumented internal method that is used is not able to handle reading only selected rows and columns.
For what you want done, you will need to use xlsread() or readtable(), or you will need to write the code yourself to read the data (perhaps using textscan())
0 Comments
See Also
Categories
Find more on Text Files 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!