db

package
v0.0.0-...-c64ded8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2021 License: Unlicense Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FoundationFoodZippedCSV = "./FoodData_Central_Foundation_Food_csv_2021-04-28.zip"
	SupportingDataZippedCSV = "./FoodData_Central_Supporting_Data_csv_2021-04-28.zip"
)

Variables

This section is empty.

Functions

func Dump

func Dump(o interface{})

func ReadZippedCSV

func ReadZippedCSV(file string, onRecord func(filename string, cols []string) error)

Types

type Category

type Category struct {
	ID          string
	Code        string // Food group code.
	Description string // Description of the food group.
}

Foods of defined similarity.

type Food

type Food struct {
	FDCID          string          // Unique permanent identifier of the food.
	Description    string          // Description of the food.
	CategoryID     string          // ID of the food category the food belongs to.
	ScientificName string          // The scientific name for the food.
	FoodKey        string          // A string of characters used to identify both the current and all historical records for a specific food.
	CategoryCode   string          // See `Category.Code`.
	CategoryDesc   string          // See `Category.Description`.
	Nutrients      []*FoodNutrient // Nutrient values this food.
}

Any substance consumed by humans for nutrition, taste and/or aroma.

type FoodDB

type FoodDB struct {
	Rows       int
	Foods      map[string]*Food
	Nutrients  map[string]*Nutrient // All nutrients in the database.
	Categories map[string]*Category // All food categories in the database.
}

func NewFoodDB

func NewFoodDB() *FoodDB

func (*FoodDB) NewDBWithUniqueFoodNamesAndAverageNutritionalValues

func (db *FoodDB) NewDBWithUniqueFoodNamesAndAverageNutritionalValues() *FoodDB

func (*FoodDB) NutrientTopList

func (db *FoodDB) NutrientTopList(nut string)

func (*FoodDB) ReadCSVRecord

func (db *FoodDB) ReadCSVRecord(csvFile string, cols []string) error

type FoodNutrient

type FoodNutrient struct {
	ID         string
	FDCID      string  // ID of the food this food nutrient pertains to.
	NutrientID string  // ID of the nutrient to which the food nutrient pertains.
	Amount     float64 // Amount of the nutrient per 100g of food. Specified in unit defined in the nutrient table.
	Name       string  // Name of the nutrient.
	UnitName   string  // The standard unit of measure for the nutrient (per 100g of food).
}

A nutrient value for a food.

type Nutrient

type Nutrient struct {
	ID          string
	Name        string // Name of the nutrient.
	UnitName    string // The standard unit of measure for the nutrient (per 100g of food).
	NutrientNbr int64  // A unique code identifying a nutrient or food constituent.
}

The chemical constituent of a food (e.g. calcium, vitamin E) officially recognized as essential to human health.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL