-
Notifications
You must be signed in to change notification settings - Fork 3
/
histogramGenerator.py
52 lines (35 loc) · 1.09 KB
/
histogramGenerator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import sys
from collections import defaultdict
minLineNum = sys.maxint
maxLineNum = -sys.maxint - 1
values = defaultdict(dict)
fileIndex = 0
for csvFile in sys.argv[1:]:
fileLines = []
for line in open(csvFile):
lineArray = line.strip().split(",")
lineNum = int(lineArray[0])
values[lineNum][fileIndex] = float(lineArray[1])
if lineNum > maxLineNum:
maxLineNum = lineNum
if lineNum < minLineNum:
minLineNum = lineNum
#fileLines.append(line.strip())
#files.append(fileLines)
fileIndex = fileIndex + 1
print(minLineNum)
print(maxLineNum)
#print(values)
outFile = open("histogram.dat", "w+")
for lineIndex in range(minLineNum, maxLineNum + 1):
outLine = "" + str(lineIndex) + "\t"
for fileIndex2 in range(0, fileIndex):
value = values[lineIndex].get(fileIndex2)
if value == None:
outLine += "0"
else:
outLine += str(value)
if fileIndex2 < (fileIndex - 1):
outLine += "\t"
outFile.write(outLine + "\n")
outFile.close()