Batch consolidation CSV is a Xlsx file

1 vue (au cours des 30 derniers jours)
一 林
一 林 le 12 Mai 2022
Commenté : 一 林 le 1 Juin 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 commentaires
Voss
Voss le 13 Mai 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?
一 林
一 林 le 1 Juin 2022
Yes, I understand that excel has restrictions on lines, so it may be necessary to change the way to achieve the goal

Connectez-vous pour commenter.

Réponses (0)

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by