🧹 remove empty amounts (e.g. '0 g')
This commit is contained in:
parent
4e8fd10413
commit
c48bc068ad
23 changed files with 101 additions and 70 deletions
|
@ -1,4 +1,6 @@
|
|||
import json
|
||||
import re
|
||||
|
||||
|
||||
input_file = 'export_2025-06-02.json'
|
||||
output_file = 'export_2025-06-02_clean.json'
|
||||
|
@ -17,6 +19,14 @@ def normalize_ingredients(recipe):
|
|||
recipe['recipeIngredient'] = [
|
||||
ingredient.replace('.0 ', ' ') for ingredient in recipe['recipeIngredient']
|
||||
]
|
||||
recipe['recipeIngredient'] = [
|
||||
re.sub("^0 (g|kg|Milliliter) ", "", ingredient) for ingredient in recipe['recipeIngredient']
|
||||
]
|
||||
recipe['recipeIngredient'] = [
|
||||
ingredient \
|
||||
for ingredient in recipe['recipeIngredient'] \
|
||||
if ingredient != "None"
|
||||
]
|
||||
return recipe
|
||||
|
||||
if isinstance(data, list):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue