Batch consolidation CSV is a Xlsx file
1 view (last 30 days)
Show older comments
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 Comments
Voss
on 13 May 2022
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?
Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!