Batch consolidation CSV is a Xlsx file
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Voss
el 13 de Mayo de 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?
Respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!