How to read all CSV files from specific folders?
177 ビュー (過去 30 日間)
古いコメントを表示
Hi, I want to open all CSV files and do a calculation on them. I used the code below and it worked
files = subdir('C:\Users\roozm\Desktop\New folder\*.csv');
Subdir function can do it easily. Now I want to be more specific and only open folder with the name of BIN and then read CSV files in only BIN folders.
How can I do that?
11 件のコメント
Paolo
2018 年 6 月 1 日
I'm not sure I understand what you mean by 'I do not know how to check if the file is in my current directory.'
Lets say your current working directory is :
C:\Users\roozm\
as from your OP. Could you list the full path of the .csv files you want, this way we can build the dir command?
回答 (3 件)
Walter Roberson
2018 年 6 月 1 日
files = dir('C:\Users\roozm\Desktop\New folder\**\BIN*\*.csv');
fullpaths = fullfile({files.folder}, {files.name});
Now fullpaths is a cell array of fully qualified .csv files that are directly under a BIN* folder anywhere under "New folder"
10 件のコメント
Roozbeh Yousefnejad
2018 年 6 月 1 日
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!