xmlutils.py icon indicating copy to clipboard operation
xmlutils.py copied to clipboard

Enable Multi-Tag Convert for CSV

Open inviscid opened this issue 10 years ago • 1 comments

This is a very useful tool for an XML file containing homogenous records. However, for XML files that contain various types of records, parsing all the record types requires scanning the file multiple times. For small XML files this is trivial but for larger GB sized XML files this is very slow.

Leveraging what you already have built, could you add a convert_multiple() method that would accept a list of tags and use the output path as the base path with the tag name appended. Something like this:

converter = xml2csv('some/path/my_xml.xml', 'some/path/my_csv_', encoding='utf8') converter.convert_multiple(tags=('tag1', 'tag2', 'tag3'))

Resulting in output files like this:

my_csv_tag1.csv my_csv_tag2.csv my_csv_tag3.csv

inviscid avatar Feb 04 '16 19:02 inviscid

@inviscid Apologies for the delayed reply. I am afraid adding a function like that to the main library may not really fit into the scope of the project. You can always extend the class and modify its behaviour.

knadh avatar Feb 09 '16 09:02 knadh