MATLAB Answers

readtable bug - if file has only one line, then readtable throws error ONLY if ReadRowNames = 1

14 views (last 30 days)
cmo on 17 Sep 2015
Answered: Peter Perkins on 21 Sep 2015
Consider a tab-delimited file with only a header line (no data otherwise)
readtable('m.txt', 'FileType', 'text', 'Delimiter', '\t', 'ReadVariableNames', 1 , 'ReadRowNames', 0)
returns an empty table, like it is supposed to.
readtable('m.txt', 'FileType', 'text', 'Delimiter', '\t', 'ReadVariableNames', 1 , 'ReadRowNames', 1)
throws an error.

Answers (1)

Peter Perkins
Peter Perkins on 21 Sep 2015
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.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!