How to merge specific rows from multiple CSV files in a single csv file in MATLAB (code)?

1 回表示 (過去 30 日間)
Abdur Rasheed
Abdur Rasheed 2022 年 9 月 5 日
回答済み: chrisw23 2022 年 9 月 6 日
I have a main folder which has 8 subfolders. Each subfolder has multiple CSV files and I need to combine all csv files into a single csv file using MATLAB code. Can anyone guide me how to start?

回答 (1 件)

chrisw23
chrisw23 2022 年 9 月 6 日
a possible start (find all csv files over subDirs)
import System.IO.*
filesFound = "";
searchOption = System.IO.SearchOption.AllDirectories;
searchDir = "C:\Temp\MainCsv";
pattern = "*.csv";
dirInfo = DirectoryInfo(searchDir);
dirInfo.EnumerateFiles(pattern, searchOption);
fsEnumerableIterator = Directory.EnumerateFiles(searchDir, pattern, searchOption);
enFilesFound = fsEnumerableIterator.GetEnumerator;
fCount = 0;
while enFilesFound.MoveNext
fCount = fCount + 1;
filesFound(fCount) = string(enFilesFound.Current);
end
for csvFile = filesFound
csvFile % open File here
end

カテゴリ

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