Skip to content

Commit

Permalink
filtered embedds from xml
Browse files Browse the repository at this point in the history
  • Loading branch information
davidschober committed Apr 1, 2024
1 parent 82d0dfc commit c51154d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nuldc/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,17 @@ def save_as_csv(headers, values, output_file):

def save_xml(data, output_file):
"""takes results as a list of dicts and writes them out to xml"""


# TODO DRY up this bit and sort_fields_and_values

ignore_fields = ['embedding', 'embedding_model']

data = [{key: value
for (key, value) in sorted(d.items())
if key not in ignore_fields} for d in data.get('data')]
xml = dicttoxml.dicttoxml(data, attr_type=False)

with open(output_file, 'wb') as xmlfile:
xmlfile.write(xml)

Expand Down

0 comments on commit c51154d

Please sign in to comment.