atviriduomenys / spinta

Spinta is a framework to describe, extract and publish data (a DEP Framework).
MIT License
10 stars 4 forks source link

Error when export data in CSV #528

Closed sirex closed 8 months ago

sirex commented 8 months ago

After upgrade, I get multiple errors like these:

Traceback (most recent call last):
  File "spinta/utils/response.py", line 246, in aiter
    for data in stream:
  File "spinta/formats/csv/commands.py", line 60, in _render_csv
    writer.writerow(row)
  File "csv.py", line 154, in writerow
    return self.writer.writerow(self._dict_to_list(rowdict))
  File "csv.py", line 149, in _dict_to_list
    raise ValueError("dict contains fields not in fieldnames: "
ValueError: dict contains fields not in fieldnames: 'sav_kodas', 'pmprs_v', 'pmprs_pk', 'pmprs_iv', 'sav_kodas_regist'
ValueError: dict contains fields not in fieldnames: 'org_savivaldybe'
ValueError: dict contains fields not in fieldnames: 'work_group', 'notification_status'

My guess, error happens, when value of a ref property is None.

sirex commented 8 months ago

Not sure if this is related, but I also get following errors:

Traceback (most recent call last):
  File "spinta/formats/rdf/commands.py", line 230, in _stream
    for row in data:
  File "spinta/commands/read.py", line 130, in <genexpr>
    commands.prepare_data_for_response(
  File "spinta/formats/rdf/commands.py", line 271, in prepare_data_for_response
    elem = commands.prepare_dtype_for_response(
  File "spinta/formats/rdf/commands.py", line 416, in prepare_dtype_for_response
    if len(data_dict) == 1 and '_id' in data_dict or '_uri' in data_dict:
TypeError: object of type 'NoneType' has no len()