Convert text file to Excel file with dates in the correct format?

1 次查看(过去 30 天)
I'm trying to get my code (below) to convert FDATA.TXT (attached) to an Excel File (attached). Once in Excel, the dates all have "0:00" after them, and I want to get rid of these 0:00 times and just have the dates shown in Excel.
The text file is generated from a SD card Arduino coded in C++ (I think?). Thanks so much!
close all
clc
T = readtable('FDATA.TXT'); % read text file
T.Var3.Format = 'MM/dd/yyyy'; % I tried adjusting the date format
writetable(T,'Initial Table Data.xlsx') % convert to Excel file
  3 个评论
Walter Roberson
Walter Roberson 2021-8-14
Is it mandatory that the Excel output have 3 columns? It would make more sense to treat the second input column as a duration to be added to the third input column as a datetime, giving you a result that is a unified datatime entry that has date and time together as a single column.

请先登录,再进行评论。

采纳的回答

Simon Chan
Simon Chan 2021-8-14
You may change it to a string format and write to an excel file.
clear; clc;
T=readtable('FDATA.TXT');
T.Var3=datestr(T.Var3,'mm/dd/yyyy');
writetable(T,'Initial Table Data.xlsx');
  3 个评论
Natalie Schmidt
Natalie Schmidt 2021-8-25
Thank you so much! While it worked for lines 1-95 in Excel, starting in line 96, the dates say "######" in Excel. (This is because the dates start repeating again in line 96 (starting again w/ 7/1/21- I don't know why). How can I fix that?

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by