Browse Source

parametrized input output files

andreagus 8 years ago
parent
commit
4fda64e934
1 changed files with 5 additions and 2 deletions
  1. 5 2
      converter.py

+ 5 - 2
converter.py

@@ -1,9 +1,12 @@
 import xml.etree.ElementTree as ET
 import csv
-tree = ET.parse('data.xml')
+import sys
+file_name_xml = sys.argv[1]
+file_name_csv = sys.argv[2]
+tree = ET.parse(file_name_xml)
 root = tree.getroot()
 
-with open('data.csv', 'wb') as csvfile:
+with open(file_name_csv, 'wb') as csvfile:
     spamwriter = csv.writer(csvfile)
     for neighbor in root.iter('DATI'):
         parent = neighbor.attrib.get("ISTANTE")