Readtable (file not getting detected in the directory)
Show older comments
Hello All,
I am trying to import files with some weird extension like '.rec1066-5(4244)','.rec1067-5(4244)'.
The extension is taken care of changing it within the code to '.txt'
But some files are getting imported while some files with similar name and same type are NOT getting imported.
the error is:
Error using readtable
Unable to find or open 'C:\Users\ashis\OneDrive\Desktop\WS\a1.txt'. Check the path and filename or file permissions.
Please help me out!! Thanks!!!
I have added the screenshot now!!
I have added two sample files to be imported. Edited the data within due to some reasons!! but the extension is still same!!
4 Comments
Cameron
on 5 Jan 2023
Can you attach any examples? It's difficult for anyone to diagnose without specifics.
Ashishkumar Gupta
on 5 Jan 2023
Image Analyst
on 5 Jan 2023
No you did not. Take 2 files with their original filenames, and zip them up into a zip file. Then attach the zip file with the paperclip icon to your reply.
Ashishkumar Gupta
on 5 Jan 2023
Accepted Answer
More Answers (1)
Fangjun Jiang
on 5 Jan 2023
0 votes
It is not robust to change the file name or create new files in the script and expect to access it right away in the script.
insert a "rehash" line before read the file. see "doc rehash"
6 Comments
Walter Roberson
on 5 Jan 2023
rehash only applies for the case where the new file is a .m file.
Ashishkumar Gupta
on 5 Jan 2023
Edited: Ashishkumar Gupta
on 5 Jan 2023
Image Analyst
on 5 Jan 2023
Again, attach a couple of files with original filenames, zipped up.
Ashishkumar Gupta
on 5 Jan 2023
Image Analyst
on 5 Jan 2023
These text files are not of a form that can be understood by readtable. You'll have to write your own custom reader for them.
Ashishkumar Gupta
on 5 Jan 2023
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!