MATLAB: Readtable splits content of file in multiple columns

MATLABreadtabletable

When I write
Countries_Europe = readtable('Countries_Europe.csv');
The contents from that file are correctly stored in a table with just one column, but when I write
Countries_NorthAmerica = readtable('Countries_NorthAmerica.csv');
then weird things happen, and a table with 5 columns is generated. Since my files have just one column, how can I make the second table to have exactly that one column as the first one, and why does this happen? Please find those files here. Thank you in advance.

Best Answer

readtable has lots of heuristics to try to determine the actual format of your file (has it got a header? how many lines is the header? What is the format of each column? What is the delimiter? etc.). It's great since you don't have to figure it out yourself but sometimes it gets it wrong. In the second case, it guesses wrongly that the delimiter is space.
You can always give hints to readtable to make its life easier. In your case, telling readtable that the delimiter is something else than space would work (there's no delimiter actually since your tables are just one column)
Countries_Europe = readtable('Countries_Europe.csv', 'Delimiter', ',');
Countries_NorthAmerica = readtable('Countries_NorthAmerica.csv', 'Delimiter', ',');