Cannot read csv with readtable (Unrecognized field name "text")
Mostrar comentarios más antiguos
Hi All,
I'm trying to read some csv data but saw the following error, for which I had absolutely no clue... Could anyone kindly help?
aaa.csv is just a simple dummy dataset I created with excel for the sake of testing.
Error from matlab:
aaa = readtable('G:\My Drive\Project_GDrive\data\aaa.csv');
Error using readtable (line 517)
Unrecognized field name "text".
Many thanks
Min
12 comentarios
aaa = readtable('aaa.csv')
Please show us the complete output from this command:
which readtable -all
Min
el 20 de En. de 2025
the cyclist
el 20 de En. de 2025
Hm, that's puzzling. I think one would typically get this error when you attempt to use an option or parameter that is not valid for the version of MATLAB you are using, or some other syntax issue.
But you seem to be using 2024a, and are not using any aditional options. Is
readtable('G:\My Drive\Project_GDrive\data\aaa.csv');
definitely the calling syntax that gives the error, or might you have called it differently?
The usual cause of that error is that you have shadowed some text function (e.g. REPLACE):
In which case you can fix it by removing/renaming the offending function.
Do you have some third-party toolbox installed or your own functions?
Min
el 20 de En. de 2025
Stephen23
el 20 de En. de 2025
Try restoredefaultpath.
Min
el 20 de En. de 2025
Stephen23
el 20 de En. de 2025
Try specifying the option FileType='text'.
Min
el 21 de En. de 2025
Stephen23
el 21 de En. de 2025
Contact TMW directly for technical support: https://www.mathworks.com/support/contact_us.html
I would suggest
dbstop if caught error
and then run the code. It should stop at the place the error actually occurs. It is quite unlikely that it is stopping at
which readtable
line 517, as that readtable has no-where near 517 lines.
Walter Roberson
el 12 de Ag. de 2025
Ah, in R2024a, readtable.m line 517 contains a throw() for an exception that was taken in another function. Tracking the problem is a bit more of a nuisance, but
dbstop if caught error
would help
Respuestas (2)
You mistyped the file name. It is read correctly - see:
D = readtable('aaa.csv');
disp(D)
4 comentarios
Min
el 21 de En. de 2025
Walter Roberson
el 10 de Ag. de 2025
Which MATLAB release are you using? In all recent versions, readtable.m itself is fairly short code, with no-where near 517 lines
I suspect that you have a third-party function with the same name as a Mathworks supplied function.
Image Analyst
el 11 de Ag. de 2025
His error message said he was using r2024a.
Min
el 12 de Ag. de 2025
Min
el 21 de En. de 2025
Movida: Walter Roberson
el 21 de En. de 2025
0 votos
1 comentario
Matteo
el 10 de Ag. de 2025
Just to support the the comment - I just had the same problem and I also was able to run the code after rebooting. The dbstop if caught error command also stops at the same place, seems to have to do with some settings from matlab.io missing the 'text' entries. Maybe these settings were modified by something else and a fresh restart ensured that they were not affected?
Categorías
Más información sobre Calendar en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
