timestamp, date formatting,csv-file

Hey Community,
Due to problems regarding xes file import, I converted the xes file into a csv file, for this I had to redefine the time stamp attribute of the type date into a string, this time stamp is now in the string format of an xes file, if you have a Idea how I change this date format so that I can also use these timestamps in my event logs for Process Mining?

the timestamp format seems like that:

2021-03-23T15:36:21.558+0100

Thank you for your Help

link of csv-file: GitHub - faruk81/xes-converted-to-csv

suppressPackageStartupMessages({
  library(lubridate)
})

string <- "2021-03-23T15:36:21.558+0100"
ymd_hms(string)
#> [1] "2021-03-23 14:36:21 UTC"

great, now I have to make this change for the whole csv file ... do you know how it is possible to change all timestamp attributes so that they got this format?

suppressPackageStartupMessages({
  library(readr)
})

DF <- read_csv("https://raw.githubusercontent.com/faruk81/xes-converted-to-csv/main/datetostring3.csv")
#> Warning: Missing column names filled in: 'X1' [1]
#> 
#> ── Column specification ────────────────────────────────────────────────────────
#> cols(
#>   .default = col_character(),
#>   X1 = col_double(),
#>   `time:timestamp` = col_datetime(format = ""),
#>   `case:concept:name` = col_double(),
#>   `Using_Time/expiry` = col_datetime(format = ""),
#>   `Using_Time/workdays` = col_logical(),
#>   Start_string = col_datetime(format = ""),
#>   End_string = col_datetime(format = ""),
#>   `Catalog/Item/OrderNo` = col_double(),
#>   `Catalog/Item/Price` = col_double(),
#>   OrderNoEntered = col_double(),
#>   Available = col_logical(),
#>   Approve = col_logical(),
#>   NewEndstring = col_datetime(format = ""),
#>   ExtensionNeeded = col_logical(),
#>   TotalPrice = col_double()
#> )
#> β„Ή Use `spec()` for the full column specifications.

head(DF)
#> # A tibble: 6 x 30
#>      X1 `time:timestamp`    `concept:name`    `lifecycle:trans… `concept:instan…
#>   <dbl> <dttm>              <chr>             <chr>             <chr>           
#> 1     0 2021-03-23 14:36:21 Fill_in_equipmen… unknown           10              
#> 2     1 2021-03-23 14:36:21 Fill_in_equipmen… unknown           10              
#> 3     2 2021-03-23 14:36:21 Fill_in_equipmen… unknown           10              
#> 4     3 2021-03-23 14:36:21 Fill_in_equipmen… schedule          10              
#> 5     4 2021-03-23 14:36:40 Fill_in_equipmen… assign            10              
#> 6     5 2021-03-23 14:36:40 Fill_in_equipmen… unknown           10              
#> # … with 25 more variables: org:resource <chr>, case:concept:name <dbl>,
#> #   Using_Time/trigger <chr>, Using_Time/expiry <dttm>,
#> #   Using_Time/workdays <lgl>, Start_string <dttm>, Requester <chr>,
#> #   End_string <dttm>, Rental_request_description <chr>, Comment <chr>,
#> #   Catalog/Item/OrderNo <dbl>, Catalog/Item/Name <chr>,
#> #   Catalog/Item/Description <chr>, Catalog/Item/Price <dbl>,
#> #   Catalog/Item/Supplier <chr>, Supplier_selected <chr>, OrderNoEntered <dbl>,
#> #   Catalog <chr>, Available <lgl>, Details_rental_request <chr>,
#> #   Request_decision <chr>, Approve <lgl>, NewEndstring <dttm>,
#> #   ExtensionNeeded <lgl>, TotalPrice <dbl>
1 Like

lol.. so easy... Thank you but now i got a new problem xD the import of the xes-file my code is that:
i actually see that read.csv and read_csv are different so with read_csv the timestamp attribute formatting automaticly

data<- read_csv("datetostring3.csv")
head(data)

it not fuction... and i want that import that new dataset :S
i got that error

Missing column names filled in: 'X1' [1]

time:timestamp,concept:name,lifecycle:transition,concept:instance,org:resource,case:concept:name,Using_Time/trigger,Using_Time/expiry,Using_Time/workdays,Start_string,Requester,End_string,Rental_request_description,Comment,Catalog/Item/OrderNo,Catalog/Item/Name,Catalog/Item/Description,Catalog/Item/Price,Catalog/Item/Supplier,Supplier_selected,OrderNoEntered,Catalog,Available,Details_rental_request,Request_decision,Approve,NewEndstring,ExtensionNeeded,TotalPrice

edit the csv file to insert a new field name

ID,time:timestamp,concept:name,lifecycle:transition,concept:instance,org:resource,case:concept:name,Using_Time/trigger,Using_Time/expiry,Using_Time/workdays,Start:timest_string,Requester,End_string,Rental_request_description,Comment,Catalog/Item/OrderNo,Catalog/Item/Name,Catalog/Item/Description,Catalog/Item/Price,Catalog/Item/Supplier,Supplier_selected,OrderNoEntered,Catalog,Available,Details_rental_request,Request_dec:timestision,Approve,NewEndstring,ExtensionNeeded,TotalPrice
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.