-
Notifications
You must be signed in to change notification settings - Fork 1
/
genGexf.py
39 lines (30 loc) · 993 Bytes
/
genGexf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sys
import os
import json
def convertJson(path):
with open(path) as f:
data = json.load(f)
arrCorrId = []
for d in data['nodes']:
arrCorrId.append(d['id'])
i = 0
for idd in arrCorrId:
os.system("sed -i 's/\"" +idd + '\"/' + str(i) + "/g' " + path)
i = i + 1
if len(sys.argv) < 2:
print "Nom du fichier contenant la liste des artistes a preciser"
#convertJson('web/gexf/Miles_Davis.json')
else:
print sys.argv[1]
f = open(sys.argv[1], 'r')
reponse = f.readlines()
# print "<select>"
for artiste in reponse:
artiste = artiste.replace('\n','')
# if( os.path.getsize("gexf/" + artiste.replace(" ","_") + ".gexf") > 1095):
# print "<option value='"+ artiste.replace(" ","_") +"'>"+ artiste + "</option>"
os.system("java -jar JazzGraph.jar '" + artiste + "' 5 json")
convertJson('web/gexf/' + artiste.replace(" ","_") + ".json")
print 'conversion du fichier json '
# print "</select>"
f.close()