Commit 88025df0 authored by Jochen Klar's avatar Jochen Klar
Browse files

Add to_csv.py tool

parent 718305cc
#!/usr/bin/env python3
import argparse
import csv
import sys
import xml.etree.ElementTree as et
nsmap = {
'dc': '{http://purl.org/dc/elements/1.1/}'
}
parser = argparse.ArgumentParser()
parser.add_argument('file')
args = parser.parse_args()
writer = csv.writer(sys.stdout, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
tree = et.parse(args.file)
root = tree.getroot()
for child in root:
uri = child.attrib['{dc}uri'.format(**nsmap)]
row = [uri] + [node.text or '' for node in child]
writer.writerow(row)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment