Doing a CSV download of a table with datetime I get dates in the format “2019-07-05A15:44:05.189000+0000”
I need to identify the specific format string so datetime.strptime() understands it.
Tried ‘%Y-%m-%d %H:%M:%S.%f%z’ which doesn’t match.
Doing a CSV download of a table with datetime I get dates in the format “2019-07-05A15:44:05.189000+0000”
I need to identify the specific format string so datetime.strptime() understands it.
Tried ‘%Y-%m-%d %H:%M:%S.%f%z’ which doesn’t match.
contains a ' '
(space) between the date and time, but the actual string contains an 'A'
in that position. Since ' ' != 'A'
, there is no match. What you’re looking for is not
%Y-%m-%d %H:%M:%S.%f%z
but
%Y-%m-%dA%H:%M:%S.%f%z
Thanks. I was trying to understand the format so I know why the ‘A’ got inserted anyway. Is it part of a specific ISO standard. Can I count on there ALWAYS being an ‘A’ there or could it vary?
I don’t know whether it can vary from one Anvil-exported CSV to the next, or not. (I suspect not.)
Other sources of CSV files certainly could vary. 'T'
is a popular separator, as is the space character. (SQLite uses both.)
A robust conversion function could simply delete the character at that position, and use
%Y-%m-%d%H:%M:%S.%f%z
Heads up, isodate
is a supported package for server code. That format looks like normal ISO 8601, so maybe the isodate
datetime parser will be able to handle it for you. I think you’d want to try isodate.parse_datetime()
List of installed packages: https://anvil.works/docs/server/packages
isodate
homepage: https://github.com/gweis/isodate/