フィルターのクリア

count the # of rows of CSV files in a folder

6 ビュー (過去 30 日間)
alpedhuez
alpedhuez 2022 年 6 月 25 日
コメント済み: Voss 2022 年 6 月 25 日
I have a bunch of CSV files in a folder. I understand that I can use
to count a number of rows of each file. Then how can one write a loop to read all csv files in a folder to calculate the sum of rows of CSV fiels in a folder?

採用された回答

Voss
Voss 2022 年 6 月 25 日
your_folder = 'C:\path\to\folder';
files = dir(fullfile(your_folder,'*.csv'));
fullFileNames = fullfile(your_folder,{files.name});
numRowsTotal = 0;
for ii = 1:numel(files)
datatable = readtable(fullFileNames{ii}, 'ReadVariableNames', false); %or true if there is a header
numRowsTotal = numRowsTotal + height(datatable);
end
  2 件のコメント
alpedhuez
alpedhuez 2022 年 6 月 25 日
Thank you.
Voss
Voss 2022 年 6 月 25 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by