readtable reading string columns as matrix when lots of empty rows.
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ryan Rose
el 29 de Jun. de 2021
Comentada: Ryan Rose
el 29 de Jun. de 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.
0 comentarios
Respuesta aceptada
Scott MacKenzie
el 29 de Jun. de 2021
Editada: Scott MacKenzie
el 29 de Jun. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!