Borrar filtros
Borrar filtros

How can I merge Excel files into only one file in Matlab?

2 visualizaciones (últimos 30 días)
NG
NG el 15 de Ag. de 2014
Comentada: Michael Haderlein el 16 de Ag. de 2014
Now I got 24 excel file in csv format , i would like to use matlab to combine all the csv files into one file , i would like to have a script to perform this .
Many thanks , Alex

Respuestas (1)

Michael Haderlein
Michael Haderlein el 15 de Ag. de 2014
files=dir('input*.csv');
output='out.csv';
fidout=fopen(output,'w');
for cnt=files'
fidin=fopen(cnt.name);
fwrite(fidout,fread(fidin));
fprintf(fidout,'\n');
fclose(fidin);
end
fclose(fidout);
  2 comentarios
NG
NG el 15 de Ag. de 2014
i have tried to use these scripts in matlab, but i cannot merge the two excel file into one. Matlab just created a new csv file .
Michael Haderlein
Michael Haderlein el 16 de Ag. de 2014
Actually, in my opinion it's the better solution to merge everything in a new file. However, if you want to merge everything in the first file, you can do that by
files=dir('input*.csv')';
fidout=fopen(files(1).name,'a');
for cnt=files(2:end)
fidin=fopen(cnt.name);
fwrite(fidout,fread(fidin));
fclose(fidin);
end
fclose(fidout);

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by