🧹 remove empty amounts (e.g. '0 g')

This commit is contained in:
neingeist 2025-06-02 09:48:27 +02:00
parent 4e8fd10413
commit c48bc068ad
23 changed files with 101 additions and 70 deletions

View file

@ -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):