Converting multiples excel files to .mat

조회 수: 4 (최근 30일)
Ibro Tutic
Ibro Tutic 2015년 10월 1일
댓글: Ibro Tutic 2015년 10월 6일
Hi all, I need to convert multiple xlsx files to .mat. The directory contains 4 folders which contain about 200 folders each which contain about 4 excel files each. How can I get MatLab to go this directory and convert every .xlsx file to .mat? I know how to do it for one file, but that doesn't help very much when I have to do it for almost a thousand files.
So far I have this:
files = dir('*.csv');
for file = files'
csv = csvread(file.name);
% Do some stuff
end
Now I need it to read every .csv file and save the data as .mat. Would this something like this work?
files = dir('*.csv');
for file = files'
csv = csvread(file.name);
save = (file.name);
end
Will this go through every folder in the directory and create .mat copies of the .csv data?
Any help appreciated.

채택된 답변

Walter Roberson
Walter Roberson 2015년 10월 1일
  댓글 수: 8
Ibro Tutic
Ibro Tutic 2015년 10월 6일
Thanks for all the help. One more question, how would I modify where I want the files saved? I would like to put them in a separate folder labeled with a time stamp so I know when all the files were converted, so when I do future conversions, I know what data is the most up to date. Again, thanks a ton.
Ibro Tutic
Ibro Tutic 2015년 10월 6일
Also, the CSV files I am reading contain text, so cvsread will not work. I am trying to implement textscan, but I am having troubles with how to set up the inputs. textscan(file,'?'). I noticed people using %f, %d, delimiter and stuff like that but I am not sure how to utilize these things to have it scan the .csv files correctly.

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

추가 답변 (0개)

카테고리

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