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.

 Réponse acceptée

dpb
dpb le 1 Déc 2017
Modifié(e) : dpb le 1 Déc 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 commentaires

dpb
dpb le 3 Déc 2017
Yea, thanks. You guess is correct.
[David's Answer moved to comment...dpb]
dpb
dpb le 3 Déc 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 le 20 Déc 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Distribution Plots dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by