#!/usr/bin/env python
# prints a nice histogram of input lines

import sys
from rasmus import tablelib

infile = sys.stdin
output = "nice"

for arg in sys.argv[1:]:
    if arg == "-t":
        output = "table"
    else:
        infile = file(arg)
        break
    

# read data
lines = []
for line in infile:
    lines.append(line.rstrip())

hist = tablelib.histtab(lines)

for row in hist:
    row['percent'] *= 100

# display histogram
if output == "nice":
    print hist.__repr__()
elif output == "table":
    hist.write()

