Convert text file to Excel file with dates in the correct format?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Natalie Schmidt
am 14 Aug. 2021
Kommentiert: Simon Chan
am 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 Kommentare
Walter Roberson
am 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.
Akzeptierte Antwort
Simon Chan
am 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!