Skip to main content

Nutrition calculation for recipes and ingredients

Project description

Nutrition calculation for recipes and ingredients

Installation

pip install foodie

Usage

from foodie import Ingredient, Recipe

apple = Food("apple", portion='160g', calories=80, protein=.5, fiber=1)
banana = Food("banana", portion='80g', calories=70, protein=1, fiber=1.6)
peanut = Food("peanut", portion='20g', calories=110, protein=5.7, fat=20, fiber=1.8)

Nutrition arithmetics

# Nutritional values of 2 apples
2 * apple
apple
{
   "portion": "320 gram",
   "dollar": "NA",
   "calories": 160,
   "protein": 1.0,
   "fiber": 2
}
# A smaller apple weighing 130g
apple.to(portion='130g')  
apple
{
   "portion": "130.0 gram",
   "dollar": "NA",
   "calories": 65.0,
   "protein": 0.41,
   "fiber": 0.81
}
# How much apple to eat to reach 3g of fibers?
apple.to(fiber=3) 
apple
{
   "portion": "480.0 gram",
   "dollar": "NA",
   "calories": 240.0,
   "protein": 1.5,
   "fiber": 3.0
}

Recipe nutritional value

# Create recipe from ingredients
recipe = Recipe("Fruit Cake", [
    2   * apple,    # 2 apple
    1   * banana,   # 1 banana
    1.5 * peanut    # 1.5 servings of peanut butter
])
recipe  # View recipie Nutritional value
Recipe (Fruit Cake):
{
   "portion": "430.0 gram",
   "dollar": "NA",
   "protein": 10.55,
   "fiber": 6.3,
   "calories": 395.0,
   "fat": 30.0
}
# Export data as CSV
recipe.export_csv("FruitCake.csv")  
name,portion,dollar,protein,fiber,calories,fat
apple,320 gram,,1.0,2,160,
banana,80 gram,,1,1.6,70,
peanut,30.0 gram,,8.55,2.7,165.0,30.0
Total,430.0 gram,,10.55,6.300000000000001,395.0,30.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nutrical-0.0.3.tar.gz (6.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page