Extract each column in excel spreadsheet and create new workbook with header as spreadsheet name

1 visualización (últimos 30 días)
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.

Respuesta aceptada

Voss
Voss el 7 de Mzo. de 2023
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

Más respuestas (0)

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by