Skip to main content

pyNutriScore

Nutri Score logo

The goal of the project is to provide simple package that can calculate the Nutri-Score.

What is the Nutri-Score ?

The Nutri-Score is a nutrition label that converts the nutritional value of products into a simple code consisting of 5 letters, each with its own colour.

Each product is awarded a score based on a scientific algorithm.

This formula takes into account the nutrients to avoid (energy value and the amount of sugars, saturated fats and salt) and the positive ones (the amount of fibre, protein, fruit, vegetables and nuts).

You can therefore see at a glance which products are recommended and which should be avoided.

Source: https://nutriscore.colruytgroup.com/colruytgroup/en/about-nutri-score/

Paper: https://pdfs.semanticscholar.org/3d1c/c206bc286bb5f80452821a0d26ff9e55b387.pdf

Where to get it

The source code is currently hosted on GitHub at: https://github.com/lemonhead94/pyNutriScore

Usage

Install

pip install pyNutriScore

Calculate the nutri-score:

from pyNutriScore import NutriScore

result = NutriScore().calculate(
    {
        'energy': 0,
        'fibers': 4,
        'fruit_percentage': 60,
        'proteins': 2,
        'saturated_fats': 2,
        'sodium': 500,
        'sugar': 10,
    },
    'solid'  # either 'solid' or 'beverage'
)

print(result)  # Output: 2

Calculate the nutri-score class:

from pyNutriScore import NutriScore

result = NutriScore().calculate_class(
    {
        'energy': 0,
        'fibers': 4,
        'fruit_percentage': 60,
        'proteins': 2,
        'saturated_fats': 2,
        'sodium': 500,
        'sugar': 10,
    },
    'solid'  # either 'solid' or 'beverage'
)

print(result)  # Output: "B"

License

MIT

Contribution

Feel free to add suggestions, PRs, comments and bug reports.

Credits

This is a re-implementation of the TypeScript package nutri-score by Alex Kolarski in Python.

Authors

Jorit Studer (jorit.studer@gmail.com)

Release files for pyNutriScore 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyNutriScore 0.0.2
File Size Uploaded
pyNutriScore-0.0.2.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyNutriScore 0.0.2
File Interpreter ABI Platform
pyNutriScore-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 13.3 kB

Release files / pyNutriScore-0.0.2.tar.gz

Download URL pyNutriScore-0.0.2.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
804aa06cc2185b1ba366505249a6d74c66c4fd7c837453fd654eb34eb36c2c6c
BLAKE2b-256 checksum
How to use checksums
6e4514daa0871b702f2691315ad30ac4d06d6e9ad3e735ceacc69dc45284115a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.7

Release files / pyNutriScore-0.0.2-py3-none-any.whl

Download URL pyNutriScore-0.0.2-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
44f2242c97962f9f78b4d918a71cd8377831b94a52891b83c2695c5b28c5dbe8
BLAKE2b-256 checksum
How to use checksums
e492e19b4e7d37417a3e87df35583e39934cdd5d435baeac4a581371d2f78999
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page