vtomar
1
I have a csv file that contains datetime column where datetime contains timezone offset. for example:
2019-01-11 17:35:00+00:00
How do I correctly specify the datetime format. I am currently specifying the format below but that only fetches 00:00 offset. How to make it generic?
df = CSV.File(filename, dateformat = “yyyy-mm-dd HH:MM:SS+00:00”)
julia> using CSV, TimeZones
julia> b = IOBuffer("stamp,value\n2023-08-11 16:30:43.853-07:00,1\n2023-08-11 16:33:42.692-07:00,1\n")
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=76, maxsize=Inf, ptr=1, mark=-1)
julia> CSV.File(b; dateformat="yyyy-mm-dd HH:MM:SS.sssz", types=Dict(:stamp=>ZonedDateTime))
2-element CSV.File:
CSV.Row: (stamp = ZonedDateTime(2023, 8, 11, 16, 30, 43, 853, tz"UTC-07:00"), value = 1)
CSV.Row: (stamp = ZonedDateTime(2023, 8, 11, 16, 33, 42, 692, tz"UTC-07:00"), value = 1)