Skip to content

Single-file mode fails to iterate over record #2

@rosiel

Description

@rosiel

Running against a single file containing a <mods> root element:

$ python3 run.py -f /PATH/MODS.xml -x test.csv -xf csv -r mods
Traceback (most recent call last):
  File "run.py", line 87, in <module>
    current_record.ordered_split()
  File "/Users/rlefaive/Git/complex_xml_to_openrefine/record.py", line 47, in ordered_split
    for k, v in self.record.items():
AttributeError: 'str' object has no attribute 'items'

If this happens in all instances (and isn't unique to python3, or my MODS that doesn't include <?xml version="1.0" encoding="UTF-8"?> at the head, or...

then the fix could be

--- a/run.py
+++ b/run.py
@@ -75,7 +75,7 @@ if __name__ == "__main__":
         real_json_call = real_json
         for x in full_path:
             real_json_call = real_json_call[x]
-        our_list_of_records = real_json_call
+        our_list_of_records = [real_json_call]
     else:
         my_source = path_to_files
         records = Batch(path_to_files)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions