From c51154d81d575a9fd7a244f554889235f1b39e19 Mon Sep 17 00:00:00 2001 From: davidschober Date: Mon, 1 Apr 2024 16:25:23 -0500 Subject: [PATCH] filtered embedds from xml --- nuldc/helpers.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nuldc/helpers.py b/nuldc/helpers.py index 5d4bb7c..033ff35 100644 --- a/nuldc/helpers.py +++ b/nuldc/helpers.py @@ -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)