Ascii Bar Charts

by @jehiah on 2010-10-20 21:30UTC
Filed under: All , Programming , Python , Data

Having just released Data Hacks a few minutes ago, i realized it would be useful to also have a cmdline way to see a bar chart of data points.

Here is a bar chart showing the requests to https://jehiah.cz/a/data-hacks over the first two hours. Thanks to a bit of love from hackernews.

Each point in this bar chart is a 10 minute segment. I’m essentially slicing my access log for the timestamp block, and then pulling out the HH:M with awk '{print $4}' | awk -F ':' '{print $2":"$3}' | cut -c '1-4'

$ grep 'GET /a/data-hacks' access.log | awk '{print $4}' | awk -F ':' '{print $2":"$3}' | cut -c '1-4' | bar_chart.py --sort-keys
# each * represents a count of 2
19:0 [     1] 
19:1 [    24] ************
19:2 [     3] *
19:3 [     9] ****
19:4 [     5] **
19:5 [    41] ********************
20:0 [   115] *********************************************************
20:1 [   181] ******************************************************************************************
20:2 [   136] ********************************************************************
20:3 [   155] *****************************************************************************
20:4 [   150] ***************************************************************************
20:5 [    79] ***************************************
21:0 [    64] ********************************
21:1 [    39] *******************

So now there is also a bar_chart.py command in github.com/bitly/data_hacks

Subscribe via RSS ı Email
Jehiah Czebotar