How to get rid of "0:00" values in generated Excel File?

조회 수: 1 (최근 30일)
Natalie Schmidt
Natalie Schmidt 2021년 8월 5일
댓글: Gaurav Aggarwal 2021년 8월 25일
I wrote Forward_Code.m (attached) to process different text files: i.e. one is FDATA.TXT (attached). It calculates the total time per month, so in the generated Excel File, there should only be one time in the "Monthly_Time" column for each month.
Two problems:
1. In the "Monthly_Time" column, there's "00:00:00" showing up in the middle of a month (ie line 36 in the Excel). How do I stop this?
2. In the 3rd Excel column, each date has a "0:00" next to it. How do I get rid of these times and just show the date?
Thanks so much!!

채택된 답변

Gaurav Aggarwal
Gaurav Aggarwal 2021년 8월 16일
편집: Gaurav Aggarwal 2021년 8월 25일
Hi Natalie,
For your 1st query,
I found a small mistake in your code. Just swap the use of idx_missing and idx2_missing (Line no. 38 and 39) for the respective columns, and the script should work correctly.
% Original Version
T.Var6(idx_missing) = missing; % Line 38
T.Var9(idx2_missing) = missing; % Line 39
% Modified Version
T.Var6(idx2_missing) = missing; % Line 38
T.Var9(idx_missing) = missing; % Line 39
For your 2nd query,
To remove the timestamp from Day column entries, you can make the below change to your code.
% Original Version
T.Var5 = NaT(Nz,1); % Line 9
% Modified Version
T.Var5 = strings(Nz,1); % Line 9
  댓글 수: 2
Natalie Schmidt
Natalie Schmidt 2021년 8월 25일
편집: Natalie Schmidt 2021년 8월 25일
Thank you! The 1st query idea worked. However, for the 2nd query, while it worked for lines 1-95, starting in line 96, the dates say "######" in Excel. (This is because the dates start repeating again in line 96 of Excel (start again w/ 7/1/21- I don't know why). How can I fix that?
Gaurav Aggarwal
Gaurav Aggarwal 2021년 8월 25일
Hi, the same works for me and I see no "######", not sure why is it happening at your end. Also, the row info that you have provided doesn't matches with the files that you have uploaded. Can you confirm it once?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by