There is error as i am trying to load .txt files from subfolders. How can i load all *.txt files using generated function (imptxt(FileName,startRow,endRow))
if trueFiles=dir('**/*AVE*.txt'); % looking for txt files with 'AVE' at the beginning
for k=1:length(Files) % k=46
FileNames=Files(k).nameendImpFiles=zeros(k,100000);for i=1:k ImpFiles(i,:)=imptxt(Files(i).name,1,1); % loading all files in one array using generated function for import
end
and i have such error:
if trueError using textscanInvalid file identifier. Use fopen to generate a valid file identifier. if trueError in imptxt (line 100034)dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', delimiter, 'TextType', 'string', 'EmptyValue', NaN, 'HeaderLines', startRow(1)-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');Error in BN (line 17)ImpFiles(k,:)=imptxt(Files(k).name,1,1); % code
end
UPD. I checked and it working but only if i start it inside one of subfolders. Otherwise it shows same error as above
Best Answer