You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to read an sdmx file (at this url: 'https://www.i14y.admin.ch/api/CodeLists/CL_HGDE_KT/exports/SDMX-ML/2.1?annotations=false') and I get errors due to the date string format. The library only allows the format %Y-%m-%d but I have date time format of the type 1978-12-31T23:00:00 in my file. Would it be possible to update the library to allow this format ?
Something like this in 'set_date_from_string' in model/utils.py
def set_date_from_string(value: str, format_: str = "%Y-%m-%dT%H:%M:%S"):
"""Generic function to format a string to datetime
Args: value: The value to be validated.
format_: A regex pattern to validate if the string has a specific format
Returns:
A datetime object
Raises:
ValueError: If the value violates the format constraint.
"""
if value is None:
return None
for fmt in (format_, "%Y-%m-%d", "%Y-%m-%dT%H:%M:%S"):
try:
return datetime.strptime(value, fmt)
except ValueError:
pass
raise ValueError(f"Wrong date string format. The formats {format_} "
f"or %Y-%m-%d or %Y-%m-%dT%H:%M:%S "
f"should be followed. {str(value)} passed")
Thank you :)
The text was updated successfully, but these errors were encountered:
Hi @paulineml . Version 1.2 of the library supports now all formats. Sorry for the delay in publishing it as we have been redesigning the whole reading and writing processes to adapt the library to SDMX 3.0 in the near future.
Hi, thank you for this library.
I am trying to read an sdmx file (at this url: 'https://www.i14y.admin.ch/api/CodeLists/CL_HGDE_KT/exports/SDMX-ML/2.1?annotations=false') and I get errors due to the date string format. The library only allows the format %Y-%m-%d but I have date time format of the type 1978-12-31T23:00:00 in my file. Would it be possible to update the library to allow this format ?
Something like this in 'set_date_from_string' in model/utils.py
Thank you :)
The text was updated successfully, but these errors were encountered: