clonegraph.py 463 Bytes
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
#!/usr/bin/python
import re
ifile = open('copy.txt','r')
ofile = open('third','w')
lines = ifile.readlines()
new_var = ''
for line in lines:
vertex_m = re.search('(vertex\s.*?\sname=)\"([a-z]+)\"',line)
edge_m = re.search('(edge\s.*\s.*\sweight=)(\S*)',line)
if vertex_m:
new_var = vertex_m.group(1) + '"a' + vertex_m.group(2) + '"'
elif edge_m:
new_var = edge_m.group(1) + '1' + edge_m.group(2)
ofile.write(new_var+'\n')

ifile.close()
ofile.close()