Can I loop xlsread to open files?
이전 댓글 표시
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
채택된 답변
추가 답변 (1개)
Walter Roberson
2011년 11월 14일
xlsread(thispath{i})
and go back to the directory structure Fangjun showed in your previous posting on this topic.
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!