Mathematica Asked by Vocis on May 21, 2021
I would like to merge two lists of strings (date and time) from my csv and then treat it as a DateObject:
time = Import[
"C:UsersData Chanel.csv",
"Table",
"FieldSeparators" -> ";",
NumberPoint -> ","][[3, 3 ;;]];
date = Import[
"C:UsersData Chanel.csv",
"Table",
"FieldSeparators" -> ";",
NumberPoint -> ","
][[2, 3 ;;]];
combFunc = Function[{date, time}, StringJoin[ToString /@ {date, time}], Listable][date, time]
timeData = DateObject[combFunc, {"Day", ". ", "MonthName", ". ", "Year", " ", "Hour", ":","Minute", ":", "Second"}]
which changes year and time in first step as it can be seen in the picture
and DateObject doesn’t work even when I apply it only on time or only on date or their combination.
Do you have any idea how to fix it?
Thank you for your advices!
Here is the link for the csv:
Assume you imported the data in time
and date
. Then we need to assemble these two in a form that suits the DateObject
:
dat= MapThread[(#1 <> " " <> #2) &, {time, date}];
Then we map DateObject
with the necessary options onto every element of the list dat
:
dates = DateObject[{#, {"Hour", "Minute", "Second" , "Day",
"MonthName", "YearShort"}} ] & /@ dat
dates is a list of DateObject
;
Correct answer by Daniel Huber on May 21, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP