フィルターのクリア

Loop through multiple csv files

6 ビュー (過去 30 日間)
mcl1993
mcl1993 2016 年 8 月 25 日
回答済み: per isakson 2016 年 8 月 25 日
I have 2550 csv files. I have created a code that calculates a value for one of the files, but i need to loop over all 2550 and add together that value calculated for each csv file.
  2 件のコメント
per isakson
per isakson 2016 年 8 月 25 日
"I have 2550 csv files" &nbsp How to make a list of these files? Are they in a special folder? Are there some special characteristics in their names?
mcl1993
mcl1993 2016 年 8 月 25 日
The csv files and .m file are all in the same folder. All the csv files are called Scan_* where * is a number

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

回答 (1 件)

per isakson
per isakson 2016 年 8 月 25 日
This is one approach, (which I like)
folderspec = 'c:\same\folder';
file_glob = 'Scan_*.csv';
sad = dir( fullfile( folderspec, file_glob ) );
for jj = 1 : length( sad )
fid = fopen( fullfile( folderspec, sad(jj).name ), 'r' );
cac = textscan( fid, ... );
fclose( fid );
...
...
end

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by