#!/usr/bin/env python import sys import math # Maximum bar width width = 120 temps = {} maximum = 0 for line in sys.stdin: (key, val) = line.strip().split("\t") key = int(key) val = int(val) temps[key] = val maximum = max(maximum, val) for key, count in sorted(temps.items(), key=lambda row: row[0]): print "{:+03d} | [{:6d}] {:s}".format(key, count, "X" * int(max(1, math.floor((count / float(maximum)) * width))))