Why is ReadTable Deleting Data with NaN?
46 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alan Lee
el 12 de Ag. de 2022
Comentada: Alan Lee
el 12 de Ag. de 2022
I'm trying to automate the reading of several hundred excel files with identical layouts using a for loop and readtable.
Does anyone know why readtable is removing data in only SOME of my columns and replacing them with NaN? I'm a bit of an amateur, so I would appreciate any help.
Excel Spreadsheet

Matlab Line
teeth = readtable(file,'Sheet','Teeth Form Sheet','Range',''); %This reads the excel file and a particular sheet and should import all the data
Table Output

2 comentarios
Respuesta aceptada
Más respuestas (1)
Cris LaPierre
el 12 de Ag. de 2022
The columns of a table must all be of the same datatype. readtable has set the datatype for each column based on the datatype in the first row. When the datatype is set to numeric and non-numeric information is encountered, it is replaced with NaN, meaning "not a number".
It looks to me like the data you want to read in is actually in rows 2-4 and 7-9. You can use the import tool to interactive create your import, or the options field of readtable.
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!