Why does readtable return invalid identifier only in 2020b

4 次查看(过去 30 天)
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