Skip to content

Aggregate a column of data in a CSV file over certain time buckets

Notifications You must be signed in to change notification settings

mcarolan/csv-bucket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

csv-bucket

Aggregate a column of data in a CSV file over certain time buckets.

I'm using this to track what I spend. I get a CSV dump of my spend from an app called toshl, tagged like so:

"Date","Entry (tags)","Expense amount","Currency","Description"
"2013-02-17","insurance","9.99","GBP",""
"2013-02-17","coke","1.5","GBP",""
"2013-02-16","booze","3.6","GBP",""
"2013-02-16","booze","3.6","GBP",""
...

I can then use csv-bucket to aggregate this data over calendar weeks or months. E.g.

$ cat input.csv | grep booze | ./csv-bucket.py --mode weekly -n
bucket,value
11th February 2013 to 17th February 2013,36.85
4th February 2013 to 10th February 2013,18.50
28th January 2013 to 3rd February 2013,37.90
21st January 2013 to 27th January 2013,10.18

Or

$ cat input.csv | grep booze | ./csv-bucket.py --mode monthly -n
bucket,value
February 2013,78.75
January 2013,24.68

I can then make a pretty graph showing my slow decent into alcoholism

About

Aggregate a column of data in a CSV file over certain time buckets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages