New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ein Datum wird bei bestimmten Sessionen nicht richtig geparst #17
Comments
Hi @bwueest since I linked this issue in SAP/python-pyodata#195 I'll reply in English. There seems to be a problem with the date parsing in pyodata, I library I'm using to make the calls to the swiss parliament webservice. Here is my current workaround to get your script to run properly, add this code after your imports and before calling swissparlpy: import pyodata
from pyodata.exceptions import PyODataModelError
# monkey-patch parse_datetime_literal
def patched_parse_datetime_literal(value):
if value == '0000-00-00T00:00:00':
return datetime.datetime(1970, 1, 1)
try:
return datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%f')
except ValueError:
try:
return datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M:%S')
except ValueError:
try:
return datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M')
except ValueError:
raise PyODataModelError(f'Cannot decode datetime from value {value}.')
pyodata.v2.model.parse_datetime_literal = patched_parse_datetime_literal I hope there will soon be a proper fix for this. |
(Author of the code that causes the problem you reported...) This should properly fix the issue: SAP/python-pyodata#197 |
Hej @metaodi and @rettichschnidi |
@bwueest pyodata 1.9.0 has just been released, so if you upgrade pyodata ( |
thanks, this is great! |
This is due to issue #17 and an error in that library
Danke vielmals für das tolle Swissparlpy-Modul! Ich habe versucht, Dein Beispiel für Votes auf den Download von Reden (Table ’Transcript’) anzuwenden, bekomme aber ein Fehler beim Parsen eines Datums.
Die Session 5002 (spp.get_data("Transcript", IdSession=5002)) geht interessanterweise, aber die Sessionen 5001 und 5003 nicht (z.B. spp.get_data("Transcript", IdSession=5001)), da bekomme ich jeweils den Fehler, dass strptime ein Datum nicht Parsen kann.
Hier mein Code:
Hier die Fehlermeldung:
Fehler_Transcripts.txt
Mein Problem ist, dass nicht ersichtlich wird, welche Variable der Fehler betrifft und ob die Einträge mit diesem Datum schlicht ignoriert werden können?
The text was updated successfully, but these errors were encountered: