Read DATE_TIME cells to python datetime object
supern8ent opened this issue · comments
When range.get_values
reads a DATE_TIME cell, you get a floating point number. For example, "4/26/2020 10:56:36" is returned as 43947.45597
.
It would be helpful to me and probably a lot of people if range.get_values
returned a datetime.datetime
object. (I noticed that writing datetimes to gsheets is implemented.)
pygsheets has the same problem with their pygsheets.worksheet.Worksheet.get_values()
, but at least I can retrieve cell.format
and, if it is DATE_TIME
, convert the floating point number to datetime (see https://stackoverflow.com/questions/47508174/convert-google-sheet-date-serial-value-into-human-readable-date)
Lastly, thank you for sheetfu! I haven't used it much yet, but the syntax and docs look great!
Thanks @supern8ent . We have an issue talking about this specifically already in here: #23
Nobody has already addresses it yet, but I may start implementing it at some point. If you feel the courage of implementing it yourself, we definitely accept PR.
Both datetime
(w/ or w/o TZ) and date
objects should ideally be bidirectionally and transparently supported. This support looks to be lacking for the most part in sheetfu
.
@impredicative @impredicative
Thanks for your feedback. Really helpful. I'm currently adding this feature on #58
It will work to the Range object and ultimately to the Table object too.
This has been implemented. Thanks for proposing the feature. This is a really cool thing.
@philippe2803 datetime support looks to be completely broken with v1.6.0. sheetfu now can't even read a table with a datetime column! It gives the error "ValueError: could not convert string to float". This used to work fine with v1.5.6. I have to roll back. sheetfu can't write a datetime object either into a table except if I convert it to a float, and this too used to work previously in v1.5.6.
@impredicative
Reopening the issue to figure this out.
Would you be able to share a sample sheet with me so I can repeat the bug and figure out where and how the bug occurs?