dr-leo / pandaSDMX

Python interface to SDMX
Apache License 2.0
129 stars 60 forks source link

IMF: XMLParseError: KeyError: 'TIME_FORMAT' #239

Open zymon opened 1 year ago

zymon commented 1 year ago

import pandasdmx as sdmx

imf = sdmx.Request("IMF") df=imf.dataflow("1PI")

Output: DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): sdmxcentral.imf.org:443 DEBUG:urllib3.connectionpool:https://sdmxcentral.imf.org:443 "GET /ws/public/sdmxapi/rest/dataflow/IMF/1PI/latest?references=all HTTP/1.1" 200 None

--- SS without DSD --- {1: False}

--- <class 'pandasdmx.message.StructureMessage'> --- {2:

id: 'IREF967191' prepared: '2023-03-07T13:45:10+00:00' receiver: sender: source: test: False} --- --- {'AGENCIES': } --- --- {'ECOFIN_DSD': } --- --- {'IMF': , 'SDMX': } --- --- {'1PI': } --- --- {'CS_SDMX_CENTRAL': } --- --- {'b5979306-0fc2-8166-4370-fbff3bdd8189': } --- --- {'CL_DATADOMAIN': , 'CL_INDICATOR': , 'CL_REF_AREA': , 'CL_AGE': , 'CL_CONF_STATUS': , 'CL_DECIMALS': , 354018: , 354019: , 354091: , 354092: , 'CL_OCCUPATION': , 'CL_SEX': , 'CL_TIME_FORMAT': , 356688: , 356689: , 357446: , 357447: , 357789: , 357790: , 357841: , 357842: , 'CL_UNIT_MULT': , 'CL_OBS_STATUS': } --- --- {'ECOFIN_CONCEPTS': , 'CROSS_DOMAIN_CONCEPTS': } --- Name --- {357890: ('en', '1PI_CONSTRAINT')} --- --- {'1PI': } --- --- {357893: , 358179: } --- Value --- {358180: 'PT1M', 358181: 'P6M', 358182: 'P3M', 358183: 'P1M', 358184: 'P1Y', 358185: 'P7D', 358186: 'P1D'} Traceback (most recent call last): File "r:\SharedLocal\Workplace\2023\03\pandasSdmx_test\.venv\Lib\site-packages\pandasdmx\reader\sdmxml.py", line 299, in read_message result = func(self, element) ^^^^^^^^^^^^^^^^^^^ File "r:\SharedLocal\Workplace\2023\03\pandasSdmx_test\.venv\Lib\site-packages\pandasdmx\reader\sdmxml.py", line 1172, in _ms arg["values_for"] = cl.get(elem.attrib["id"]) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "r:\SharedLocal\Workplace\2023\03\pandasSdmx_test\.venv\Lib\site-packages\pandasdmx\model.py", line 883, in get raise KeyError(id) KeyError: 'TIME_FORMAT' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "", line 1, in File "r:\SharedLocal\Workplace\2023\03\pandasSdmx_test\.venv\Lib\site-packages\pandasdmx\api.py", line 514, in get msg = reader.read_message(response_content, dsd=kwargs.get("dsd", None)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "r:\SharedLocal\Workplace\2023\03\pandasSdmx_test\.venv\Lib\site-packages\pandasdmx\reader\sdmxml.py", line 316, in read_message raise XMLParseError from exc pandasdmx.exceptions.XMLParseError: KeyError: 'TIME_FORMAT' This was first discovered in sdmx1: https://github.com/khaeru/sdmx/issues/102