czarandy / usda

Code to import USDA nutrition info into a database

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The USDA has a database of nutritional information for many foods available at:

  http://www.ars.usda.gov/Services/docs.htm?docid=8964

By default it's contained in flat files. This project includes scripts to generate appropriate schema and import them into a SQLite database. I've also hand generated a subset of the nutrients that includes commonly-familiar nutrients vs. the very extensive list provided by the USDA.

You will need to first download the files and unzip them into the data directory, e.g. for release SR24

  cd data
  wget http://www.ars.usda.gov/SP2UserFiles/Place/12354500/Data/SR24/dnload/sr24.zip
  unzip sr24.zip

Then just run create_db.sh with the name of the file you want to make:

  ./create_db.sh usda.sql3

For convenience I've included the data files for SR24 in the data directory. I've also included the resulting db for convenience if you just want to use it directly. On my system it takes about 10 seconds to populate the db.

I've included two simple python scripts that let you search for food items and print out nutritional facts in json.

About

Code to import USDA nutrition info into a database


Languages

Language:Python 74.3%Language:Shell 25.7%