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.

 採用された回答

dpb
dpb 2017 年 12 月 1 日
編集済み: dpb 2017 年 12 月 1 日

0 投票

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 件のコメント

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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Distribution Plots についてさらに検索

タグ

質問済み:

2017 年 12 月 1 日

コメント済み:

2017 年 12 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by