3
$\begingroup$

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:\\Users\\Data Chanel.csv",
    "Table",
    "FieldSeparators" -> ";",
    NumberPoint -> ","][[3, 3 ;;]];
    date = Import[
         "C:\\Users\\Data Chanel.csv",
         "Table",
         "FieldSeparators" -> ";",
         NumberPoint -> ","
    ][[2, 3 ;;]];


combFunc =  Function[{date, time}, StringJoin[ToString /@ {date, time}], Listable][date, time]

And the result is: enter image description here

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:

https://gofile.io/d/I6scno

$\endgroup$
3
$\begingroup$

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;

date[[1;;2]]

$\endgroup$
2
$\begingroup$
imported = Import["Data Chanel 1.csv", "Table", "FieldSeparators" -> ";"];

dates = DateObject[#2 ~~ " " ~~ #3]& @@@ Transpose@ imported[[All, 2 ;;]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.