Python US CPI Fork

2013/02/05

Download the latest US CPI spreadsheet (.csv, updated nightly)

Update March 2014: Unfortunately, this library no longer works because the Bureau of Labor Statistics changed their site.

After searching for what I thought was a very simple thing, a CSV/spreadsheet file of the latest Consumer Price Index data from the US government (used for calculating inflation), I found that it was not easy to find.

Instead of manually wrangling the weirdly-formatted government-released data into a spreadsheet myself, I decided to write a tool to do it for me! I wrote a Python library that downloads the latest CPI data and outputs it as a CSV file (compatible with Excel, Google Docs, and Open Office, downloadable above). Now anyone can have a nice spreadsheet of the latest consumer price index data! The python file can be run from the command line which will output a CSV file in the current working directory. You can also use the Python class in your own Python applications; it comes with a built-in inflation calculator as well as a function for returning the average indexes for a given year. Happy inflating!

View/fork/download the python code on Github