Open with one click!
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
if len(sys.argv) != 2:
8
print "Usage: " + sys.argv[0] + " data_file"
9
10
if not os.path.exists(sys.argv[1]):
11
print "file " + sys.argv[1] + " does not exist."
12
sys.exit(1)
13
14
data = open(sys.argv[1], "r").read() # we have tons of memory
15
16
i = 0
17
data = data[string.find(data,"J["):]
18
while string.find(data,"J[") != -1:
19
data = data[string.find(data,"J[")+2:]
20
j = string.find(data,"]")
21
N = data[:j]
22
data = data[string.find(data,"analytic_sha_upper_bounds := ")+len("analytic_sha_upper_bounds := "):]
23
i = string.find(data,"],")
24
f = data[:i+1]
25
data = data[i+2:]
26
print N,":",f
27
fname = "outsha/" + str(N)
28
print "fname = ", fname
29
out = open(fname,"w")
30
out.write(f)
31
out.close()
32
os.system('bzip2 -f -- "%s"'%fname)
33
34
35
36
37