Effacer les filtres
Effacer les filtres

readtable reading string columns as matrix when lots of empty rows.

13 vues (au cours des 30 derniers jours)
Ryan Rose
Ryan Rose le 29 Juin 2021
Commenté : Ryan Rose le 29 Juin 2021
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.

Réponse acceptée

Scott MacKenzie
Scott MacKenzie le 29 Juin 2021
Modifié(e) : Scott MacKenzie le 29 Juin 2021
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.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by