Why does readtable return invalid identifier only in 2020b

4 views (last 30 days)
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 Comment
dpb
dpb on 21 Jun 2022
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)
...

Sign in to comment.

Accepted Answer

Daniel Klisiewicz
Daniel Klisiewicz on 22 Jun 2022
Edited: Daniel Klisiewicz on 22 Jun 2022
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 Comment
dpb
dpb on 23 Jun 2022
Edited: dpb on 23 Jun 2022
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!