Some-Soft / FitTracker

1 stars 0 forks source link

Find data source of products #46

Closed pd-dudkiewicz closed 9 months ago

pd-dudkiewicz commented 11 months ago
PiotrMichalak1 commented 9 months ago

https://api.data.gov/docs/developer-manual/ api key: 4zjAvTZf1QlLw2AbfaeMP7QOyxXUJcCRiE0XAIv4

Sample GET requests: https://api.nal.usda.gov/fdc/v1/foods/search?api_key=4zjAvTZf1QlLw2AbfaeMP7QOyxXUJcCRiE0XAIv4&query=Bread https://api.nal.usda.gov/fdc/v1/foods/search?api_key=4zjAvTZf1QlLw2AbfaeMP7QOyxXUJcCRiE0XAIv4

https://corgis-edu.github.io/corgis/csv/food/ +ready csv +appears to be calculated per 100g -no calorie count (able to count from fat,carbs,total lipid) -many products are repeated, need to pick one of a kind (as there is 5000 positions every 10th should do the job)

https://tools.myfooddata.com/nutrition-facts-database-spreadsheet.php

+xlsx (I have already converted to JSON) +servings per 100g +calories, fat, carbs, protein given (I rounded fat carbs, protein to integers)

example:

{
      "name": "Bread White Wheat",
      "kcal": "238",
      "carbs ": "44",
      "protein": "11",
      "fat": "2"
    },
    {
      "name": "Bagels Wheat",
      "kcal": "250",
      "carbs ": "49",
      "protein": "10",
      "fat": "2"
    },
    {
      "name": "Cream Puff Eclair Custard Or Cream Filled Iced",
      "kcal": "334",
      "carbs ": "37",
      "protein": "4",
      "fat": "19"
    },
    {
      "name": "Tortillas Ready-To-Bake Or -Fry Flour Shelf Stable",
      "kcal": "297",
      "carbs ": "49",
      "protein": "8",
      "fat": "8"
    },
pd-dudkiewicz commented 9 months ago

Let's use https://corgis-edu.github.io/corgis/csv/food/

  1. Find 500 most used products (GPT help)
  2. Find these 500 products in CSV file
  3. Check what was found in 2.
  4. Discuss
pd-dudkiewicz commented 9 months ago

Script nr 1:

  1. import csv
  2. array of objects [ { "name": "chleb super pyszny", "carb": "", "protein": "", "fat": "" }, {}, {}, ... ]
  3. most used products list (get from GPT) - go one by one
  4. search each in array (from step 2) - find words (separated by space, comma, etc.)
    • get 5 by least number of other characters
  5. save json (key - name, value: array of max 5 options) { "chleb" [ { "name": "chleb super pyszny", "carb": "", "protein": "", "fat": "" }, {}, {}, ], "jajko": [], ... } 5.1. create csv (name, options, choice index)
  6. go through 500 products, make a choice, save csv

Script nr 2:

  1. open csv, get choices, look into json saved in step 5
  2. output array with choices - use original choice name (object: picked option) [ { "name": "chleb super pyszny", "carb": "", "protein": "", "fat": "" } ]
PiotrMichalak1 commented 9 months ago

JSON with 640 products created successfully.