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.

 Akzeptierte Antwort

dpb
dpb am 1 Dez. 2017
Bearbeitet: dpb am 1 Dez. 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 Kommentare

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Distribution Plots finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 1 Dez. 2017

Kommentiert:

am 22 Dez. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by