Importing excel time data

65 views (last 30 days)
MBUNYA NERVILLE ANYANG
MBUNYA NERVILLE ANYANG on 24 May 2023
Commented: Mathieu NOE on 25 May 2023
I am trying to read an excel file containg the date and time in the format "dd/mm/yyyy HH:MM:SS". (The excel contains eight columns [Date, Time, data1, data2, data3,data4,data5,data6,data7,data8])
I read the excel file with the code
opts = detectImportOptions("LW.xlsx");
T = readtable("LW.xlsx",opts)
T = 240×8 table
Date Time T DH DN E GH Z _____ ________ ____ ___ ___ __ ___ ___ 39083 0 22.7 0 0 0 0 155 39083 0.041667 22.5 0 0 0 0 144 39083 0.083333 22 0 0 0 0 132 39083 0.125 21.8 0 0 0 0 118 39083 0.16667 21.6 0 0 0 0 104 39083 0.20833 21.7 7 0 0 7 91 39083 0.25 22.2 81 59 2 84 77 39083 0.29167 23.6 183 205 7 190 64 39083 0.33333 25 311 319 0 311 51 39083 0.375 26 457 324 0 457 39 39083 0.41667 27 536 346 0 536 31 39083 0.45833 27.6 566 362 0 566 28 39083 0.5 27.6 506 276 0 506 32 39083 0.54167 27.5 361 242 0 361 41 39083 0.58333 27.2 313 210 0 313 53 39083 0.625 26.6 209 173 12 221 65
T = table2timetable(T)
Error using table2timetable
Input table must contain datetime or duration vector for row times.
Time =datetime(T.Time, "ConverFrom", "datenum", "Format", "HH:mm:ss");
Date =datetime(T.Date, "ConverFrom", "datenum", "Format", "dd/MM/yyyy");
TD = mergevars(T,{"Date","Time"},...
"NewVariableName","DateTime", "MergeAsTable",true);
I get error message when I try table2timetable and also when I try to merge Time and Date
How do I fix this please.
  1 Comment
Mathieu NOE
Mathieu NOE on 24 May 2023
hi
it would be helpfull to share your excel file as well

Sign in to comment.

Answers (1)

Luca Ferro
Luca Ferro on 24 May 2023
  4 Comments
Mathieu NOE
Mathieu NOE on 25 May 2023
make sure you have read / write permission on your path
are you sure you are not working in a windows protected path ?

Sign in to comment.

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!