Can I loop xlsread to open files?
Ältere Kommentare anzeigen
Basically I want to open a bunch of Yahoo Finance FIles and parse them because they come in a really ugly format (can't use csvread).
How would I fix this code to be able to open the existing files in a directory. I have written the following:
Now once i've opened each one, how do i grab the values for A and newmat and put them together in a matrix and output a .csv file with them together in in 'c:\Users\Laurentiu Galan\Desktop\tickoutput3\*.csv'?
Thanks. I have no idea how to use the directory so if i could do it with xlsread that would be great. Other users have suggested that in the past, but I cant get that to work.
%Matlab code to create matrix for files
Files = dir('c:\Users\Laurentiu Galan\Desktop\tickoutput2\*.csv');
fnames = {Files.name};
filename = fnames';
%Determine Size for Loop
D = size(filename);
Numloop = D(1,1);
%Loop to Create Paths for each file
for i=1:Numloop
thispath(i,1) = strcat('c:\Users\Laurentiu Galan\Desktop\tickoutput\', filename(i,1));
end;
%Loop to Loop
for i=Numloop
[numericalData, textData] = xlsread('thispath(i)');
newmat=flipud(numericalData(2:end, 6));
A = flipud(textData(2:end, 1));
end
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 14 Nov. 2011
xlsread(thispath{i})
and go back to the directory structure Fangjun showed in your previous posting on this topic.
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!