Cannot read csv with readtable (Unrecognized field name "text")

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 件のコメント

Stephen23
Stephen23 2025 年 1 月 20 日
aaa = readtable('aaa.csv')
aaa = 5x4 table
srgae regse esgrse dgfc _____ _____ ______ __________ 1 2 3 {'sredgr'} 5 64 353 {'fggd' } 242 353 32 {'fgwt' } 64 56 465 {'xg' } 3 324 4245 {'wwet' }
Please show us the complete output from this command:
which readtable -all
/MATLAB/toolbox/matlab/iofun/readtable.m /MATLAB/toolbox/shared/io/general/+matlab/+io/@ImportOptions/ImportOptions.m % matlab.io.text.DelimitedTextImportOptions method
Min
Min 2025 年 1 月 20 日
Many thanks @Stephen23!
This is what I was expecting! I tried to read the original csv and saw the same error, then created a dummy simple dataset, but still the same error...
This is what I see from `which readtable -all`
>> which readtable -all
C:\Program Files\MATLAB\R2024a\toolbox\matlab\iofun\readtable.m
C:\Program Files\MATLAB\R2024a\toolbox\shared\io\general\+matlab\+io\@ImportOptions\ImportOptions.m % matlab.io.ImportOptions method
Best
Min
the cyclist
the cyclist 2025 年 1 月 20 日
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?
Stephen23
Stephen23 2025 年 1 月 20 日
編集済み: Stephen23 2025 年 1 月 20 日
Min
Min 2025 年 1 月 20 日
@the cyclist: I tried to save the file in different location (e.g. readtable("C:\Users\minuser\Desktop\abc.csv") so that the space in the path is gone), but still the same error...
@Stephen23: It's a fresh installation and the following add-ons are installed. But I don't think I have other third party toolbox installed.
Stephen23
Stephen23 2025 年 1 月 20 日
Try restoredefaultpath.
Min
Min 2025 年 1 月 20 日
@Stephen23: like this? But the error seems to be the same as before. There must be something weird going on...
>> restoredefaultpath
>>
>>
aaa = readtable("C:\Users\minuser\Desktop\abc.csv")
Error using readtable (line 517)
Unrecognized field name "text".
Stephen23
Stephen23 2025 年 1 月 20 日
Try specifying the option FileType='text'.
Min
Min 2025 年 1 月 21 日
still the same error...
>>
aaa = readtable("C:\Users\sunm25\Desktop\aaa.csv", FileType='text')
Error using readtable (line 517)
Unrecognized field name "text".
>>
aaa = readtable('G:\My Drive\Project_GDrive\MMP9\data\aaa.csv', FileType='text');
Error using readtable (line 517)
Unrecognized field name "text".
Stephen23
Stephen23 2025 年 1 月 21 日
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
/MATLAB/toolbox/matlab/iofun/readtable.m
line 517, as that readtable has no-where near 517 lines.
Walter Roberson
Walter Roberson 2025 年 8 月 12 日
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

サインインしてコメントする。

回答 (2 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2025 年 1 月 20 日

0 投票

You mistyped the file name. It is read correctly - see:
D = readtable('aaa.csv');
disp(D)
srgae regse esgrse dgfc _____ _____ ______ __________ 1 2 3 {'sredgr'} 5 64 353 {'fggd' } 242 353 32 {'fgwt' } 64 56 465 {'xg' } 3 324 4245 {'wwet' }

4 件のコメント

Min
Min 2025 年 1 月 21 日
I don't think it's to do with misspelling...
>>
aaa = readtable('G:\My Drive\Project_GDrive\MMP9\data\aaa.csv');
Error using readtable (line 517)
Unrecognized field name "text".
>>
aaa = readtable("C:\Users\minuser\Desktop\aaa.csv");
Error using readtable (line 517)
Unrecognized field name "text".
Walter Roberson
Walter Roberson 2025 年 8 月 10 日
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
Image Analyst 2025 年 8 月 11 日
His error message said he was using r2024a.
Min
Min 2025 年 8 月 12 日
Thanks both. The issue is solved after a reboot. The reasons I really don't know...

サインインしてコメントする。

Min
Min 2025 年 1 月 21 日
移動済み: Walter Roberson 2025 年 1 月 21 日

0 投票

many thanks all! After rebooting the error is gone... Probably only god knows why...

1 件のコメント

Matteo
Matteo 2025 年 8 月 10 日
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?

サインインしてコメントする。

カテゴリ

製品

リリース

R2024a

タグ

質問済み:

Min
2025 年 1 月 20 日

コメント済み:

Min
2025 年 8 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by