Convert text file to Excel file with dates in the correct format?
4 views (last 30 days)
Show older comments
Natalie Schmidt
on 14 Aug 2021
Commented: Simon Chan
on 26 Aug 2021
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 Comments
Walter Roberson
on 14 Aug 2021
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.
Accepted Answer
Simon Chan
on 14 Aug 2021
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 Comments
More Answers (0)
See Also
Categories
Find more on Data Import from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!