Open files with for loop with character as title
Afficher commentaires plus anciens
Hi,
I have a bunch of files to open and they are classed by month. Usually I would use a for loop and num2str to convert numbered month to string to read them, however the months are written in characters (AUGUST, MAY, etc)
Anyone knows how to solve this issue without changing the name of the files one by one?
Thanks in advance!
Réponse acceptée
Plus de réponses (1)
bym
le 15 Août 2011
something like this?
fileInfo = dir('*.csv'); % csv files in directory
numFile = length(fileInfo);
rawData = cell(1,numFile);
for i = 1:numFile
fid = fopen(fileInfo(i).name);
rawData{i} = textscan(fid,'%*s%*s%*s%s%*s%f','delimiter',',');
fclose(fid);
end
1 commentaire
Wei
le 16 Août 2011
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!