projects
/
erange.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Release version for Erange 4.0a
[erange.git]
/
binstocdf.py
diff --git
a/binstocdf.py
b/binstocdf.py
index 63aa9558b8848183d4528bb16149cd0ced38aadd..27b48e22e8ecde5b4fd9c817ff17d4ab75dcbd13 100755
(executable)
--- a/
binstocdf.py
+++ b/
binstocdf.py
@@
-1,4
+1,5
@@
import sys
import sys
+import string
print "binstocdf: version 1.1"
print "binstocdf: version 1.1"
@@
-6,19
+7,19
@@
def main(argv=None):
if not argv:
argv = sys.argv
if not argv:
argv = sys.argv
- if len(argv) <
2
:
- print
'usage: python %s infile outfile'
% sys.argv[0]
+ if len(argv) <
3
:
+ print
"usage: python %s infile outfile"
% sys.argv[0]
sys.exit(1)
sys.exit(1)
- infilename = argv[
0
]
- outfilename = argv[
1
]
+ infilename = argv[
1
]
+ outfilename = argv[
2
]
binToCDF(infilename, outfilename)
def binToCDF(infilename, outfilename):
infile = open(infilename)
binToCDF(infilename, outfilename)
def binToCDF(infilename, outfilename):
infile = open(infilename)
- outfile = open(outfilename,
'w'
)
+ outfile = open(outfilename,
"w"
)
for line in infile:
fields = line.strip().split()
for line in infile:
fields = line.strip().split()
@@
-30,14
+31,15
@@
def binToCDF(infilename, outfilename):
outfile.write(line)
continue
outfile.write(line)
continue
- out
file.write('%s\t%s\t%s\t%s' % (fields[0], fields[1], fields[2], fields[3]))
-
cum
= 0
+ out
putFields = fields[:4]
+
runningTotal
= 0
for bin in fields[4:]:
for bin in fields[4:]:
-
cum
+= int(bin)
- percent = 100 *
cum
/ total
- out
file.write('\t%d'
% percent)
+
runningTotal
+= int(bin)
+ percent = 100 *
runningTotal
/ total
+ out
putFields.append("%d"
% percent)
- outfile.write('\n')
+ outputLine = string.join(outputFields, "\t")
+ outfile.write("%s\n" % outputLine)
infile.close()
outfile.close()
infile.close()
outfile.close()