CoCalc Public Fileswww / tables / j0n_invariants / transform_oddintmat.pyOpen with one click!
Author: William A. Stein
1
#! /usr/bin/python
2
# transform.py -- transform data's data into my database format.
3
# William Stein
4
5
import os, string, sys
6
7
OUTDIR = "/home/was/magma_database/data/odd_intersection_matrix_gamma0.data/"
8
9
if len(sys.argv) != 2:
10
print "Usage: " + sys.argv[0] + " data_file"
11
12
if not os.path.exists(sys.argv[1]):
13
print "file " + sys.argv[1] + " does not exist."
14
sys.exit(1)
15
16
data = open(sys.argv[1], "r").read() # we have tons of memory
17
18
i = 0
19
data = data[string.find(data,"J["):]
20
while string.find(data,"J[") != -1:
21
data = data[string.find(data,"J[")+2:]
22
j = string.find(data,"]")
23
N = data[:j]
24
data = data[string.find(data,"intersection_graph := ")+len("intersection_graph := "):]
25
i = string.find(data,"],")
26
f = data[:i+1]
27
data = data[i+2:]
28
print N,":",f
29
fname = OUTDIR + "[%s,2]"%str(N)
30
print "fname = ", fname
31
out = open(fname,"w")
32
out.write(f)
33
out.close()
34
os.system('bzip2 -f -- "%s"'%fname)
35
36
37
38
39