-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResultWriter.py
More file actions
37 lines (23 loc) · 804 Bytes
/
ResultWriter.py
File metadata and controls
37 lines (23 loc) · 804 Bytes
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
class ResultWriter(object):
def __init__(self, output):
self.output = output
'''
Write given result to whatever output we've specificed.
'''
def write_result(self, col_names, rows):
if (col_names is None or rows is None):
return
header = ""
num_underscores = 0
for col in col_names:
header += "{0:>7}".format(col)
num_underscores += 7
header += "\n"
header += "-" * num_underscores + "\n"
self.output.write(header)
for row in rows:
row_string = "".join("{0: >7}".format(k) for k in row) + "\n"
self.output.write(row_string)
self.output.write("\n")
return
# end write_result