read table in excel file and save under a different name
3 次查看(过去 30 天)
显示 更早的评论
Hi,
How can I read the table in a excel file with numbers and letters? This is saved as test.xls (see the attachment). Then I need to save as ALDA.xls.
Thanks in advance.
1999 ALDA 1/14/1999 12:00 1999 1 14 12 -20.2 36.1
1999 ALDA 1/14/1999 15:00 1999 1 14 15 -20.3 36.25
1999 ALDA 1/14/1999 18:00 1999 1 14 18 -20.4 36.4
1999 ALDA 1/14/1999 21:00 1999 1 14 21 -20.35 36.3
1999 ALDA 1/15/1999 0:00 1999 1 15 0 -20.3 36.2
1999 ALDA 1/15/1999 3:00 1999 1 15 3 -20.25 36.2
0 个评论
回答(2 个)
Peter Perkins
2015-2-27
Damith, if you have a recent version of MATLAB (R2013b or newer), you should be able to read the spreadsheet with the readtable function. If you happen to have ER2014b, some of those data look like you could convert to datetimes in the table that readtable will return.
Image Analyst
2015-2-27
Why not just copy it with copyfile()?
copyfile('test.xls', 'ALDA.xls');
2 个评论
Image Analyst
2015-2-28
Well you've probably figured it out by now but I couldn't get back to it until now. But for what it's worth, here is my code:
filename = 'test_new.xls';
[num, txt,raw] = xlsread(filename);
dividerRow = find(isnan(num(:,1))) + 1;
ca1 = raw(1:dividerRow-1,:)
xlswrite('Astride.xlsx', ca1);
ca2 = raw(1,:); % Get header line.
ca2 = [ca2;raw(dividerRow+1:end, :)]
xlswrite('Babiola.xlsx', ca2);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!