MATLAB Answers

readtable truncates rownames if using ReadRowNames

9 views (last 30 days)
cmo
cmo on 14 Sep 2015
Commented: Peter Perkins on 21 Sep 2015
One of the options for "readtable" is "ReadRowNames".
Apparently, when "ReadRowNames" is true, Matlab silently truncates the length of rownames to a maximum of 63 characters.
However, if you manually assigned row names to a table in Matlab, they can be of arbitrary length. (e.g. myTable.Properties.RowNames = cellArrayOfVeryLongStrings works and does not truncate row names.)
No warning is given, and this "feature" is not mentioned in any documentation or Matlab tutorial on Tables.
Note that Matlab issues various warnings when, say, Variable Names for table are too long, non-unique, contain invalid characters, etc. The crime here is that Matlab automatically "formats" incoming rownames in "readtable" without any warning or notification.

  0 Comments

Sign in to comment.

Accepted Answer

Peter Perkins
Peter Perkins on 15 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.
Just out of curiosity, what names do you have that are more than 63 characters?

  1 Comment

Peter Perkins
Peter Perkins on 21 Sep 2015
cmo, I really was asking about those long names. It helps to know how people are using MATLAB, and this seems like maybe a case we'd like to know about. Thanks.

Sign in to comment.

More Answers (0)

Sign in to answer this question.