source: branches/MetisMQI/script/parseXMLOutput.py

Last change on this file was 29, checked in by gnappo, 14 years ago

Taggata versione per la demo e aggiunto branch.

  • Property svn:executable set to *
File size: 1.4 KB
Line 
1#!/usr/bin/python
2
3import statistics
4import xml.dom.minidom
5import sys
6import re
7from re import split
8from math import sqrt
9import os
10
11def getText(nodelist):
12    rc = []
13    for node in nodelist:
14        if node.nodeType == node.TEXT_NODE:
15            rc.append(node.data)
16    return ''.join(rc)
17
18def handleCluster(cluster):
19    numberOfVertices = getText(cluster.getElementsByTagName("vertex")[0].childNodes)
20    conductance = getText(cluster.getElementsByTagName("conductance")[0].childNodes)
21    print numberOfVertices + " " + conductance
22
23def handleClusters(clusters):
24    for cluster in clusters.getElementsByTagName("cluster"):
25        handleCluster(cluster)
26
27def handleRun(run):
28    clusters = run.getElementsByTagName("clusters")[0]
29    handleClusters(clusters)
30
31fileXML = sys.argv[1]
32dom = xml.dom.minidom.parse(fileXML)
33handleRun(dom)
34
35
36
37
38
39
40
41
42#basedir = sys.argv[1]
43
44#filesList = [basedir + file for file in os.listdir(basedir) if (re.match('.*dat$', file) and not re.match('^output.*', file))]
45
46#results = []
47#for file in filesList:
48#    inp = open(file,"r")
49#    values = []
50#    for line in inp.readlines():
51#        values.append(float(line))
52#    inp.close()
53#    print "File ",file," acquisito."
54#    results.append(statistics.mean(values))
55#variance = statistics.variance(results, mode = "Unbiased")
56#confidence = sqrt(variance / len(results)) * 1.6449
57#print "Average: ",statistics.mean(results)," Confidence interval: ",confidence
Note: See TracBrowser for help on using the repository browser.