Skip to content

Instantly share code, notes, and snippets.

Created November 15, 2011 11:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1366875 to your computer and use it in GitHub Desktop.
Save anonymous/1366875 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# -*- coding: UTF-8 -*-
BARS = u'▁▂▃▅▆▇'
import sys
data = sys.argv[1:] or sys.stdin.read().split()
data = (x.strip() for x in data)
data = [float(x) for x in data if x]
incr = min(data)
width = max(data) / len(BARS)
bins = [i*width+incr for i in range(len(BARS))]
indexes = [i for n in data
for i, thres in enumerate(bins)
if thres <= n < thres+width]
print ''.join(BARS[i] for i in indexes)
@hugo-dc
Copy link

hugo-dc commented May 8, 2013

What can I do if my terminal doesn't support unicode?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment