Batch consolidation CSV is a Xlsx file
1 次查看(过去 30 天)
显示 更早的评论
function MultXlsIntoOne(inputFolder,outputFolder,outputFileName)
% Get all CSV lists
dirOutput = dir(fullfile(inputFolder,'*.csv'));
fileNames = {dirOutput.name}';
fileNum = length(fileNames);
idx = 1;
for fileidx = 1:fileNum
% Read CSV content
disp([num2str(fileidx),'--',fileNames{fileidx}])
[~,~,info] = xlsread(fullfile(inputFolder,fileNames{fileidx}));
% write in
xlswrite(fullfile(outputFolder,outputFileName),info,1,['A',num2str(idx)])
% update
infonum = size(info,1);
idx = idx+infonum;
end
disp('finish')
end
Using this code can merge about 171 files, but I need to merge about 200 files. How can I update the code?
2 个评论
Voss
2022-5-13
The code will read all .csv files in inputFolder and write their contents in sequence to the output file.
If inputFolder contains 171 .csv files, then 171 .csv files will be combined in the output file. If inputFolder contains 200 .csv files, then 200 .csv files will be combined in the output file.
What problem are you running into? Is it that you have 200 files but only the first 171 appear to be written to the output file?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!