Skip to content

Draft: Do not build element dicts but element rows for CSV export

ml bonhomme requested to merge revamp into master
  • Make it actually work 🙂 things are not in the right order probably because this cool looking thing
      for column in metadata_columns:
              element_row.append(
                  next(
                      (item.value for item in element_md if item.name == column),
                      None,
                  )
              )
    does not do what I want it to; maybe this did:
    if with_metadata and metadata_columns:
          element_md = element_metadata(item.id, load_parents=with_parent_metadata)
          # For each column name append metadata value or an empty string in the correct column order
          for column in sorted(set(metadata_columns)):
              mds = [md.value for md in element_md if md.name == column]
              column_count = len([col for col in metadata_columns if col == column])
              assert len(mds) <= column_count, "Metadata and column count mismatch"
              i = 1
              for md in mds:
                  element_row.append(md.value)
                  i += 1
              while i < column_count:
                  element_row.append("")
  • tests
  • docs

Merge request reports

Loading