MATLAB Answers

readtable bug with tab delimiter and commas within a field.

21 views (last 30 days)
cmo on 17 Sep 2015
Commented: Peter Perkins on 21 Sep 2015
Consider a tab-delimited text file, in which a given field may contain a string with commas, e.g.
Matlab's "readtable" function with delimiter=\t will parse the third field ("C,D,E") into multiple lines, rather than treating it as one field.
That is, the command:
readtable( filename, 'FileType', 'text', 'Delimiter', '\t', 'ReadRowNames', 0 , 'ReadVariableNames', 0)
will NOT return a table with the 3rd column/Variable having value "C,D,E" but rather split that field into multiple lines/entries (very strange).


dpb on 17 Sep 2015
Guess I'm not terribly surprised by the behavior. Report bugs to TMW at
I'd guess for the moment the only choice would be to change the comma character in the string to something else to read the data/create the table. I'd expect you could then make the change back internally within the table if it's significant.
Chris Turnes
Chris Turnes on 18 Sep 2015
Can you post a small portion of your file that can reproduce the issue? I wasn't able to reproduce with a file that was:
You might also want to try specifying the 'Format' parameter and see if that helps.
Peter Perkins
Peter Perkins on 21 Sep 2015
cmo, I can't reproduce this in any version of MATLAB since R2013b. You haven't said what version or platform you're running on.

Sign in to comment.

Answers (0)


Community Treasure Hunt

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

Start Hunting!

Translated by