MATLAB: Read multiple csv files and extract first 10 rows only

csv read

I have multiple (more than 100) csv files. I want a loop to read the csv files and extract only first ten rows from each csv files.
Thanks!

Best Answer

Just read each file in turn and save the first N lines...
NLines=10; % how many wanted to save...make variable so can change at will...
d=dir('Appropriate*WildCardPattern*.csv');
for i=1:numel(d)
data=csvread(d(i).name);
data=data(1:NLines,:);
...
% do whatever with this file's data here...
end
Related Question