Importing excel time data

50 次查看(过去 30 天)
MBUNYA NERVILLE ANYANG
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 个)

Luca Ferro
Luca Ferro 2023-5-24
  4 个评论
Mathieu NOE
Mathieu NOE 2023-5-25
make sure you have read / write permission on your path
are you sure you are not working in a windows protected path ?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 App Building 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by