Skip to content

Instantly share code, notes, and snippets.

@egonw
Forked from samuell/plot_file_sizes.py
Created May 17, 2017 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egonw/798b9a3813ee094aa155a4dff44eef0f to your computer and use it in GitHub Desktop.
Save egonw/798b9a3813ee094aa155a4dff44eef0f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from sys import stdin, stdout
import csv
rdr = csv.reader(stdin, delimiter='\t')
wrt = csv.writer(stdout, delimiter='\t')
vals = []
rows = []
for row in rdr:
val = row[0]
val = val.replace(',','.').replace('K', '*1000').replace('M', '*1000000').replace('G', '*1000000000')
exec('val=' + val)
vals.append(val)
rows.append(row)
max = max(vals)
for v, r in zip(vals,rows):
fname = r[1]
graph = ('*'*round((v / max) * 100))
print(fname.rjust(64), graph, r[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment