readtable bug - if file has only one line, then readtable throws error ONLY if ReadRowNames = 1
Ältere Kommentare anzeigen
Consider a tab-delimited file with only a header line (no data otherwise)
e.g.
m.txt:
name<tab>age
Then
readtable('m.txt', 'FileType', 'text', 'Delimiter', '\t', 'ReadVariableNames', 1 , 'ReadRowNames', 0)
returns an empty table, like it is supposed to.
However
readtable('m.txt', 'FileType', 'text', 'Delimiter', '\t', 'ReadVariableNames', 1 , 'ReadRowNames', 1)
throws an error.
1 Kommentar
dpb
am 18 Sep. 2015
Bug reports to www.mathworks.com Meanwhile, if this is an issue, a workaround would be try...catch around the call...
Antworten (1)
Peter Perkins
am 21 Sep. 2015
1 Stimme
cmo, you are correct, thank you for finding this bug. I will make a note to have it fixed. For the time being, you can read in the file with ReadRowNames set to false, and then assign the row names and delete the string variable.
1 Kommentar
Burton Filstrup
am 8 Nov. 2022
Still broken in MATLAB 2022a.
Kategorien
Mehr zu Tables finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!