필터 지우기
필터 지우기

Why does readtable return invalid identifier only in 2020b

조회 수: 5 (최근 30일)
Daniel Klisiewicz
Daniel Klisiewicz 2022년 6월 21일
편집: dpb 2022년 6월 23일
I have a comma delimited file in my home directory. I am able to import this file using 'readtable' in Matlab 2018b. I am unable to import data from this file using 'readtable' in Matlab 2020b. I receive the generic "Invalid file identifier" error.
I looked into the matlab internal functions, and I've found the root of why it can't see the file:
in +matlab/+io/+internal/+functions/ExecutableFunction line 61, it assigns the input of 'readtable' into the Filename field of the function object. Regardless of how I enter the argument ('/home/user/file','/home/user/file.csv',fullfile('/','home','user','file'), 'file') this line doubles up the path so that matlab thinks its looking for the file:
/home/user/home/user/file.
Is there a bug with 2020b? Or is there some setting/option somewhere that I might need to fix? The 2018b version of readtable seems to not use this internal io function package.
  댓글 수: 1
dpb
dpb 2022년 6월 21일
I'm using R2020b and have seen no such symptoms with readtable and friends...which update are you running? If there were some bug and a patch, maybe need a given update, but I don't recall having seen such a symptom of any complaints here, either...
It would seem this would be a problem no matter where the file is located -- show us exact code entered and error in context and complete.
Here's output of ver for R2020b here that seems not to have any issues...on Win10, anyways; gather you may be on another OS, though.
>> ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.9.0.1718557 (R2020b) Update 6
MATLAB License Number: xxxxxx
Operating System: Microsoft Windows 10 Pro Version 10.0 (Build 19043)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB Version 9.9 (R2020b)
...

댓글을 달려면 로그인하십시오.

채택된 답변

Daniel Klisiewicz
Daniel Klisiewicz 2022년 6월 22일
편집: Daniel Klisiewicz 2022년 6월 22일
It turns out I had a directory structure in the /home/user/ folder that was also named "/home/user/". Deep in the file validation tree there is a line in
+matlab/+io/+internal/+functions/AcceptsReadableFilename.m line 51
that says:
path = fileparts(fn{1});
if isempty(path) || isfolder(fullfile(pwd,path))
fn{1} = fullfile(pwd,fn{1});
end
where fn{1} is the filename - in my case /home/user/file. So, if there is a directory that matches the working directory of the file to be read within the working directory, then matlab will prepend an extra pwd to the filename.
I'm not sure what the intention is behind the isfolder portion, but, in my EXTREME edge case, this resulted in undesired behavior.
  댓글 수: 1
dpb
dpb 2022년 6월 23일
편집: dpb 2022년 6월 23일
Indeed, that would be an unusual directory structure, but it isn't illegal.
I'd suggest this would be worthy of a bug report--would have to scratch head more to decipher what, precisely, the purpose was intended to be, but one guesses that is attempt to ensure not an empty path and the case you have wasn't considered as possible.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by