Explorar el Código

refactored script with polished starting xml

andreagus hace 8 años
padre
commit
274d321f8b
Se han modificado 2 ficheros con 5 adiciones y 9 borrados
  1. 5 9
      converter.py
  2. 0 0
      data.xml

+ 5 - 9
converter.py

@@ -3,16 +3,12 @@ import csv
 tree = ET.parse('data.xml')
 root = tree.getroot()
 
-
-
-
-
 with open('data.csv', 'wb') as csvfile:
     spamwriter = csv.writer(csvfile)
     for neighbor in root.iter('DATI'):
         parent = neighbor.attrib.get("ISTANTE")
-        temp = ""
-        for child in neighbor:
-            temp = temp + child.text + ","
-        temp = temp[:-1]
-        spamwriter.writerow([parent, temp])
+        parent = parent[:-4]
+        vm = neighbor[0].text
+        vmin = neighbor[1].text
+        vmax = neighbor[1].text
+        spamwriter.writerow([parent, vm, vmin, vmax])

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
data.xml


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio