フィルターのクリア

read multiple csv files and extract first 10 rows only

20 ビュー (過去 30 日間)
MatLab Code N
MatLab Code N 2019 年 5 月 13 日
コメント済み: dpb 2019 年 5 月 13 日
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!

採用された回答

dpb
dpb 2019 年 5 月 13 日
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
  2 件のコメント
MatLab Code N
MatLab Code N 2019 年 5 月 13 日
Your code gave me an error. So, i've attached two of my sample files. I hope this might help you to debug the problem.
Thank you so much!
dpb
dpb 2019 年 5 月 13 日
You said were .csv files...those are Excel files--use an appropriate way to read Excell file.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by