필터 지우기
필터 지우기

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

조회 수: 8 (최근 30일)
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.

답변 (1개)

Benjamin Ye
Benjamin Ye 2019년 6월 13일
편집: Benjamin Ye 2019년 6월 13일
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.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by