Convert multiple csv to xls files.

조회 수: 23 (최근 30일)
avantika . 2013년 10월 25일
댓글: Marcos dos Santos . 2021년 4월 16일
I have a folder containing many excel files ( more than 200) in csv format . I need to write all these files in xls format.
Can this be done in matlab . Can anyone please help.
Thanks in advance

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 10월 25일
편집: Azzi Abdelmalek 님. 2013년 10월 25일
d=dir([yourfolder '\*.csv']);
for k=1:numel(files)
[~,~,b] = xlsread(old_name) ;
  댓글 수: 7
Onur ALPAY 2020년 12월 8일
I am using MATLAB 2019a version and it looks there is no problem with version. I try this code but I realized that the below code doesn't work. It gives me the same file name. Do you have any experiance about that?
new_name = strrep(old_name,'csv','xls')

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Fabian Neira
Fabian Neira 2018년 6월 1일
I got the following error "File name must be a character vector" when using the code.
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 6월 1일
Please post your code.

댓글을 달려면 로그인하십시오.

Lotan Jackson
Lotan Jackson 2020년 8월 25일
Hi everyone, I know this is an old question but I had to adjust things for either the newest version or being on a newest matlab version. Here's the code. I placed all the files in the folder with the script.
file = dir('*.csv');
s= size(file,1);
for i= 1:s
Data = readtable(file(i).name);
filename= filename(1:end-5);
writetable(Data,[filename '.xls']);
Hope this helps anyone in the future. :)
  댓글 수: 1
Marcos dos Santos
Marcos dos Santos 2021년 4월 16일
It helped me. Thank you, Lotan!

댓글을 달려면 로그인하십시오.


Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기


Community Treasure Hunt

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

Start Hunting!

Translated by