Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get Nutrition Facts for Branded Foods? #124

Open
hhimanshu opened this issue Apr 14, 2023 · 1 comment
Open

How to get Nutrition Facts for Branded Foods? #124

hhimanshu opened this issue Apr 14, 2023 · 1 comment

Comments

@hhimanshu
Copy link

Hello,
As I try to understand the dataset more, I am not clear on how to get the nutrients for a specific branded food. I will post my understanding below and hope that you will be able to spot the gap correct me.

Also, I am using latest dataset from Oct 2022

Here it goes

  1. The uniqueness of a branded food is identified with gtin_upc field.
  2. The branded_food.csv has one or more records for a given gtin_upc field. This is based on when the product is available and when it was modified or discontinued.
  3. To find the latest record for a branded food, I get the latest fdc_id by sorting the rows (in descending order) first by available_date, then by modified_date. Then, I pick the first row, and therefore get the fdc_id.
  4. For this fdc_id, I search in food_nutrient.csv file. My understanding is that with this query, I will be able to fetch all the nutrients for this branded food product.

Unfortunately, I believe my understanding is not correct. For example, Let’s take the following product

  1. gtin_upc is 810041590039
  2. The latest fdc_id available (as per Oct 2022 dataset, the website has one more record) is 2330624.
  3. With this fdc_id, when I query in food_nutrient table, I get no results. That means that the latest fdc_id for a given gtin_upc is no enough to retrieve the nutrients for the product.
  4. The direct link for the food is https://fdc.nal.usda.gov/fdc-app.html#/food-details/2487349/nutrients.

So what shall I do to get the latest nutrients for a branded food product? One way is to get all fdc_ids for an associated gtin_upc. Then, starting from the oldest fdc_id, create a map of nutrients. If, there is a new or updated nutrient found, update the map. By the end of this exercise, there will be a Map that contains all nutrients for the product. However, how to deal with siutations when a nutrient is not added or updated, rather deleted?

Please guide me so that I can get the latest nutrients for a product uniquely identified with gtin_upc.

Thank you

@ideaguy3d
Copy link

I agree. Extracting nutrition facts is currently not straightforward. This should be improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants