I use Matlab2018b on iOS. csvread does not work. file not found

i use this code
validdatatypes = {'.csv'};
strPath = dir('/Users/***/mess1600');
lPath = struct2cell(strPath)';
lPath = lPath(cell2mat(lPath(:,strcmp('isdir',fieldnames(strPath)))) == 0 & contains(lPath(:,1),validdatatypes),:);
lPath = cellfun(@(a,b) [b '\' a],lPath(:,1),lPath(:,2),'uniformoutput',0);
format long;
data = cell(numel(lPath),1);
for n = 1:numel(lPath)
data{n} = csvread(lPath{n},3,0);
end
error is:
Error using csvread (line 35)
File not found.
Error in export (line 10)
data{n} = csvread(lPath{n},3,0);
anybody got an idea? it worked on windows

2 Comments

means the file does not exist in your working directory
but the file does exist

Sign in to comment.

Answers (1)

madhan ravi
madhan ravi on 15 Dec 2018
Edited: madhan ravi on 15 Dec 2018
Processing sequence of files (use xlsread() or readtable() to read the file)

8 Comments

still the same error. file not found. i mean everything else works. in lPath are all the directorys.
cant, contains personal info. but i can tell you that in lpath there are directorys all sorted nicely in a 6x1 cell. and i have 6 csv files to read. however csvread somehow cant open the files and get their info into data{}. as i told in the beginning. it works fine with windows. only problem i have is here on iOS. could it be a bug?
use xlsread() or readtable() ??
i also tried to just set up a simple excel file with some values in it. used my code. everything works, my code finds the .xlsx document when i change .csv to .xlsx in validdatatypes and csvread to xlsread. however xlsread does not work. it says: file not found. unable to open file with directory ('rigth directory')
Benn's answer moved here for consistency:
i tried something else. i guess i know what the mistake is, but cant handle it. the pathnames in lPath are missing this: '..' around them, thats why csvread cant open them. how to i add those somehow?

Sign in to comment.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products

Asked:

on 15 Dec 2018

Commented:

on 15 Dec 2018

Community Treasure Hunt

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

Start Hunting!