#!/bin/python
from decimal import *
import re
infile = open('in.txt', 'r')
outfile = open('out.txt', 'w')
pattern = '[0-9]E\+[0-9]'
pattern1 = '[0-9]E\-[0-9]'
array = []
for line in infile:
array.append( line )
data = line.split()
n =0
for i in data:
str1 = 'data['+str(n)+'] = '
print str1
print data[n]
print "\n"
if re.search(pattern,i) or re.search(pattern1,i):
print "Match"
print i
print "\n, convert"
s = Decimal(i).normalize()
print s
print"$$$$\n"
n = n + 1
mylist = map(lambda(x): str(x), dataout)
outfile.writelines(mylist)
outfile.write("\n")
infile.close()
outfile.close()
Monday, October 3, 2011
A little python script to convert a file with scientific notation to decimal notation, line by line.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment