Extra variable when opening a file using readtable.

Has anyone experienced the problem of getting an extra column of data at the very end of the datasset when using readtable() to open a file? For instance, if the file has 20 columns of data, then the output will have a 21st column named Var21 which is always NaNs. I'm not sure if it's a problem with the files that I'm reading or something else.

 Respuesta aceptada

dpb
dpb el 1 de Dic. de 2017
Editada: dpb el 1 de Dic. de 2017
Even without seeing the files, with almost 100% certainty there's an extra delimiter at the end of the record which makes it look like an empty data field. If the record were
1,2,3,
4,5,6,
...
for instance, then to the input parser it is
value delim value delim value delim \n
so the sequence between the final delimiter and the newline (\n) is interpreted as missing data.

5 comentarios

dpb
dpb el 3 de Dic. de 2017
Yea, thanks. You guess is correct.
[David's Answer moved to comment...dpb]
dpb
dpb el 3 de Dic. de 2017
Please accept the Answer if it did solve the problem (to indicate closed topic to others if nothing else)...
In recent versions of MATLAB, you should be able to use importoptions to control how this phantom column is handled.
dpb
dpb el 20 de Dic. de 2017
Which function(s) are cognizant of importoptions, Peter?
At the moment, I believe it's just readtable.
Also I should correct myself: the function is named detectImportOptions.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Distribution Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 1 de Dic. de 2017

Comentada:

el 22 de Dic. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by