readtable reading string columns as matrix when lots of empty rows.
10 ビュー (過去 30 日間)
古いコメントを表示
I work with very large tables (3 million or so rows). I use the readtable function to import them into matlab. recently I noticed a bug, when I have a large amount of empty cells in a column that is supposed to be a column of strings. readtable reads the column as a matrix and all the cells are NaN. Is there a way to set specific columns to be read as cells or chars to prevent this problem. I would prefer to not format all the columns as matlab is pretty good at this already and they can move around and change.
The code works fine with smaller data or if the strings show up earlier in the data.
Any help would be appriciated.
0 件のコメント
採用された回答
Scott MacKenzie
2021 年 6 月 29 日
編集済み: Scott MacKenzie
2021 年 6 月 29 日
You ask: Is there a way to set specific columns to be read as cells? Yes, you can do this:
opts = detectImportOptions('filenname.xlsx');
opts = setvartype(opts, {'name_of_column'}, 'cell');
T = readtable('filename.xlsx', opts);
See the readtable documentation for a detailed example.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!