You will need to download and place in the /data folder the following files from ftp://pi.super-computing.org/:
Each one is 100 million digits of pi encoded as a hexadecimal byte.
This script will convert them to decimal text files.
In [6]:
import os
for i in range(10):
infilename = 'data/pi100m.hexbin.00' + str(i)
outfilename = 'data/pi100m.dectxt.00' + str(i)
if not os.path.isfile(outfilename): #nothing will be carried out if decimal text file already exists
with open(infilename, 'rb') as fin:
pi_partial = fin.read().encode('hex')
print "Processing %s, %d digits, %s...%s" % (outfilename,
len(pi_partial),
pi_partial[:20],
pi_partial[-20:])
with open(outfilename, 'w+') as fout:
fout.write(pi_partial)
In [1]:
# Create 1000-character files for overlaps during tests
filelist = ['data/pi100m.dectxt.001', 'data/pi100m.dectxt.002', 'data/pi100m.dectxt.003',
'data/pi100m.dectxt.004', 'data/pi100m.dectxt.005', 'data/pi100m.dectxt.006',
'data/pi100m.dectxt.007', 'data/pi100m.dectxt.008', 'data/pi100m.dectxt.009']
for filename in filelist:
current = open(filename, 'r')
string1K = current.read()[:1000]
current.close()
newfile = open(filename+'.1K', 'w+')
newfile.write(string1K)
newfile.close()
In [ ]: