Converting CSV files to xlsm excel worksheet

4 visualizaciones (últimos 30 días)
naouras saleh
naouras saleh el 29 de Sept. de 2020
Respondida: Walter Roberson el 29 de Sept. de 2020
Hi
I have a folder containing many excel files ( more than 300) in csv format . I need to write all these files in xlsm excel work sheet.
Can this be done in matlab . Can anyone please help.
below, i have attach how the converting looks like.
thank you very much

Respuestas (1)

Walter Roberson
Walter Roberson el 29 de Sept. de 2020
Because you have a mix of datatypes in the file, I recommend that you fopen() each file, and that you textscan() the next two lines with format '%s%s%s%s%s' and 'delimiter', ';' . Save the resulting cell array A for later.
Then textscan() one line with format repmat('%s',1,13) and delimiter ';' . Save the resulting cell array B for later.
Then textscan() the remaining lines with format
['%{hh:mm:ss}T', repmat('%f', 1, 16)]
Save the resulting cell array C for later.
Now let
D = cell(size(C{1},1)+3, 17);
D(1:2, 1:5) = A;
D(3, :) = B;
D(4:end) = num2cell(cell2mat(C));
or something like that.
Now writecell() D if you have R2019b or later.
Or you perhaps might want to work in three sections, writing each section in turn, using the range specifications; the advantage of doing that is that you would not have to fiddle around with padding the arrays out to the widest (17).

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by