Filter löschen
Filter löschen

Updated to MATLAB 2019a and having an issue with the read table function for .csv

8 Ansichten (letzte 30 Tage)
I recently updated to MATLAB 2019a and I am having an issue with the readtable function. Prior to this I had MATLAB 2018a, and the function worked fine. Here is my code:
t = readtable(tempfilename);
Where tempfilename is a .csv file. This is the error I keep getting:
Error using readtable (line 216)
Expected a cell array of valid variable names.
Note: readtable detected the following parameters:
'Delimiter', ',', 'HeaderLines', , 'ReadVariableNames', true, 'Format', ''
I'm not sure what about the update caused this error to start or how to fix it.

Antworten (1)

Benjamin Ye
Benjamin Ye am 13 Jun. 2019
Bearbeitet: Benjamin Ye am 13 Jun. 2019
Looks like MATLAB now checks whether the imported header names are less than 63 characters, which is the limit for variable names. Not sure why they consider header names to be variable names, since they're stored in cells. So if your header names are longer than that, readtable() no longer works. I have the same issue and have reverted back to 2018b.
Alternatively, and this is not recommended since I'm not sure if it breaks anything else, you could remove the check ~all(cellfun(@isvarname,rhs) in line 165 in ImportOptions.m. I was able to get my old script with the readtable() function to work.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by