Batch consolidation CSV is a Xlsx file

1 visualización (últimos 30 días)
一 林
一 林 el 12 de Mayo de 2022
Comentada: 一 林 el 1 de Jun. de 2022
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
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?
一 林
一 林 el 1 de Jun. de 2022
Yes, I understand that excel has restrictions on lines, so it may be necessary to change the way to achieve the goal

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by