Parse::USDA::NNDB - download and parse the latest USDA National Nutrient Database
version 0.1
use Parse::USDA::NNDB; my $usda = Parse::USDA::NNDB->new($optional_cache_dir); $usda->open_file( 'FD_GROUP' ); while (my $fg = $usda->getline) { printf "ID: %s DESC: %s\n", $fg->{NDB_No}, $fg->{Shrt_Desc}; }
Parse::USDA::NNDB is for parsing the nutrient data files made available by the USDA in ASCII format. If the files are not available, they will be automatically retrieved and extracted for you.
Creates a new Parse::USDA::NNDB object. Takes one optional argument, a path to the dir which contains the datafiles to be parsed.
Call with the case-insensitive name of the file, without extension, to open. You must call this before get_line.
Returns true on success.
After open_file, keep calling this to get the next line. Each line is a hashref (see USDA docs for their meanings).
Returns undef when the file is finished or if something goes wrong.
Returns a list of all the known tables/filenames.
Returns a list of the keys used in this file.
USDA documentation
Ioan Rogers <ioan.rogers@gmail.com>
This software is Copyright (c) 2012 by Ioan Rogers.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Parse::USDA::NNDB, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Parse::USDA::NNDB
CPAN shell
perl -MCPAN -e shell install Parse::USDA::NNDB
For more information on module installation, please visit the detailed CPAN module installation guide.