How can I merge Excel files into only one file in Matlab?
1 回表示 (過去 30 日間)
古いコメントを表示
Now I got 24 excel file in csv format , i would like to use matlab to combine all the csv files into one file , i would like to have a script to perform this .
Many thanks , Alex
0 件のコメント
回答 (1 件)
Michael Haderlein
2014 年 8 月 15 日
files=dir('input*.csv');
output='out.csv';
fidout=fopen(output,'w');
for cnt=files'
fidin=fopen(cnt.name);
fwrite(fidout,fread(fidin));
fprintf(fidout,'\n');
fclose(fidin);
end
fclose(fidout);
2 件のコメント
Michael Haderlein
2014 年 8 月 16 日
Actually, in my opinion it's the better solution to merge everything in a new file. However, if you want to merge everything in the first file, you can do that by
files=dir('input*.csv')';
fidout=fopen(files(1).name,'a');
for cnt=files(2:end)
fidin=fopen(cnt.name);
fwrite(fidout,fread(fidin));
fclose(fidin);
end
fclose(fidout);
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!