Import the USDA National Nutrient Database for Standard Reference into a Sqlite3 database. Tested on ruby 1.9.2.
-
Download and the ASCII version of the SR26 database from the Nutrient Data Laboratory Home Page. There is a 7.6 Mb ZIP file containing the entire database.
-
Extract the database into this project's top-level directory. It will create a subdirectory called 'sr26' and should look like:
sr26/Data_src.pdf sr26/DATA_SRC.txt sr26/DATSRCLN.txt sr26/DERIV_CD.txt sr26/FD_GROUP.txt sr26/FOOD_DES.txt sr26/FOOTNOTE.txt sr26/LANGDESC.txt sr26/LANGUAL.txt sr26/NUT_DATA.txt sr26/NUTR_DEF.txt sr26/sr26_doc.pdf sr26/SRC_CD.txt sr26/WEIGHT.txt
-
Requires bundler. Run
bundle install
to install required gems if needed. -
Run
rake load
to create database and, optionally,rake pivot
to create a flattened table with nutrient values (pivot task requires fts4 extensions to Sqlite).