-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Hi! Reading date columns throws multiple warnings.
Consider the following table with a couple empty (None) rows:
my_date
0 2021-12-01T00:00:00Z
1 2021-12-01T00:00:00Z
2 None
3 None
4 None
Fetching the my_date column throws two types of warnings:
>>> base.query('SELECT my_date FROM MyTable')
[Warning] format date: Invalid isoformat string: '2021-12-01T00:00:00Z'
[Warning] format date: Invalid isoformat string: '2021-12-01T00:00:00Z'
[Warning] format date: fromisoformat: argument must be str
[Warning] format date: fromisoformat: argument must be str
[Warning] format date: fromisoformat: argument must be str
[{'my_date': '2021-12-01T00:00:00Z'},
{'my_date': '2021-12-01T00:00:00Z'},
{'my_date': None},
{'my_date': None},
{'my_date': None}]- Invalid isoformat string:
The culprit for this appears to be this line:
seatable-api-python/seatable_api/utils.py
Line 139 in 9922141
| date_value = datetime.fromisoformat(value) |
Apparently, datetime.fromisoformat does not like the trailing Z (see this post on stack overflow):
- Argument must be a str:
The problem here is that the same try/except block as above does not cater for empty rows.
These issues are obviously not show stoppers but since each row will cause a warning (that can't be suppressed because it's a print statement) this becomes really annoying for longer tables.
On a general note: Is that implicit (re-)formatting strictly necessary? For example, I'm typically converting data into pandas data frames anyway and pandas.to_datetime() has no issues with the full string - even parses the correct time zone:
>>> pd.to_datetime('2021-12-01T00:00:00Z')
Timestamp('2021-12-01 00:00:00+0000', tz='UTC')FYI: This is with seatable_api version 2.5.1.
I also have a separate question on writing dates to SeaTable: I've tried writing a timestamp back to the table (via batch update) and it appears as if for iso-formatted strings (e.g. 2021-12-01T11:00:05Z) the date is correct ingested but the time is dropped. Can you tell me what the expected format is?
Thanks,
Philipp