Extract each column in excel spreadsheet and create new workbook with header as spreadsheet name
1 次查看(过去 30 天)
显示 更早的评论
Hello. I have a spreadsheet, "CatchCount1.xlsx", and in the spreadsheet, the first column header is "date", and the following column headers are zip code values (i.e. for column B1 the header is 10458, for column c1, the header is 10457, and so forth for all 178 zip codes.).
Basically, for each date, there are values for each zip code.
I want to create separate spreadsheets for each zip code, where the zip code value is the name of the excel spreadsheet. I want to keep the date header in column A, and for the header of Column B, it would say Catch.
So, for zip code 10458, it would have its own spreadsheet named "10458.xlsx". The column A would have "date" as a header and the dates listed from A2:A3653, and for column B, it would have "Catch" as a header, and the values of B2:B3653 would be the same as for the original "CatchCount1.xlsx". For zip code 10457, the column A would have "date" as a header and the dates listed from A2:3653, and for column B, it would have "Catch" as a header, and the values of C2:C3653. And so forth for each zip code. For each zip code, I would like this.
I would appreciate any help. Thanks.
0 个评论
采纳的回答
Voss
2023-3-7
C = readcell('CatchCount1.xlsx');
for ii = 2:size(C,2)
C_new = C(:,[1 ii]);
C_new{1,2} = 'Catch';
writecell(C_new,sprintf('%d.xlsx',C{1,ii}));
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!