필터 지우기
필터 지우기

Converting CSV files to xlsm excel worksheet

조회 수: 1 (최근 30일)
naouras saleh
naouras saleh 2020년 9월 29일
답변: Walter Roberson 2020년 9월 29일
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

답변 (1개)

Walter Roberson
Walter Roberson 2020년 9월 29일
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).

카테고리

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