Importing multiple CSV files to process in a loop...

3 views (last 30 days)
kieran
kieran on 16 Apr 2014
Commented: dpb on 16 Apr 2014
Hi,
I have around 60 CSV files I need to import to a script all of which have names like trial02, trial03, trial04 etc. and I only wish to take one column from each to be processed, also they are not the same length, here is what I have so far...
%%Define Variables
nsub=70; %Number of subjects
g=-9.81; %gravity
freq=1/1000; %sample freqency (1000Hz)
%%Importing Files
for i=2:nsub
trail1=-xlsread('groupAmain/Trial0.CSV', 'Trial02', 'E6:E2337');
%%Calculating Jump Height
ftest=find(trail1<=0);%How many 0 readings
ft=length(ftest)*0.001; %Time of flight
pk_disp=(0*(ft/2))-(0.5*g*(ft/2)^2); %Peak Jump Height using vt-0.5*a*t^2
end
Thanks
  1 Comment
dpb
dpb on 16 Apr 2014
I'd go at it a little differently but before posting specific code, what's in the remaining columns? Since you don't know the length a priori and xlsread needs a square boundary, I'd look at just reading the file and throwing away the columns you don't need. If it's all numeric that's trivial, if mixed types a little more effort but as long as all are same data in same columns, no big deal. But need to know that much at least...

Sign in to comment.

Answers (0)

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!