From 16bf04300b802631d1fb135b780e13e21069ac76 Mon Sep 17 00:00:00 2001 From: edouardbruelhart Date: Tue, 11 Jun 2024 19:53:13 +0200 Subject: [PATCH] added index = False to .to_csv to avoid doing shit in the csvs --- stock_manager/main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stock_manager/main.py b/stock_manager/main.py index 2fb93f0..7f62a8d 100644 --- a/stock_manager/main.py +++ b/stock_manager/main.py @@ -221,10 +221,10 @@ def __init__(self, add: tk.Toplevel, root: tk.Tk): # Sort data alphabetically df_ingredients = pd.read_csv(path_ingredients) df_ingredients_sorted = df_ingredients.sort_values(by=["type_ingredient", "ingredient"]) - df_ingredients_sorted.to_csv(path_ingredients) + df_ingredients_sorted.to_csv(path_ingredients, index=False) df_recettes = pd.read_csv(path_recettes) df_recettes_sorted = df_recettes.sort_values(by="nom_biere") - df_recettes_sorted.to_csv(path_recettes) + df_recettes_sorted.to_csv(path_recettes, index=False) # Load sorted data self.df_recettes = pd.read_csv(path_recettes) @@ -420,10 +420,10 @@ def __init__(self, remove: tk.Toplevel, root: tk.Tk): # Sort data alphabetically df_ingredients = pd.read_csv(path_ingredients) df_ingredients_sorted = df_ingredients.sort_values(by=["type_ingredient", "ingredient"]) - df_ingredients_sorted.to_csv(path_ingredients) + df_ingredients_sorted.to_csv(path_ingredients, index=False) df_recettes = pd.read_csv(path_recettes) df_recettes_sorted = df_recettes.sort_values(by="nom_biere") - df_recettes_sorted.to_csv(path_recettes) + df_recettes_sorted.to_csv(path_recettes, index=False) # Load sorted data self.df_recettes = pd.read_csv(path_recettes) @@ -953,7 +953,7 @@ def save_recipe(self) -> None: # Sort data alphabetically df_recettes = pd.read_csv(path_recettes) df_recettes_sorted = df_recettes.sort_values(by="nom_biere") - df_recettes_sorted.to_csv(path_recettes) + df_recettes_sorted.to_csv(path_recettes, index=False) else: self.status_write.config(text="Aucune recette définie!", foreground="red") @@ -1014,7 +1014,7 @@ def add_ingredient(self, ingredient_type: str, ingredient: str, rounded: int) -> # Sort data alphabetically df_ingredients = pd.read_csv(path_ingredient) df_ingredients_sorted = df_ingredients.sort_values(by=["type_ingredient", "ingredient"]) - df_ingredients_sorted.to_csv(path_ingredient) + df_ingredients_sorted.to_csv(path_ingredient, index=False) else: # If ingredient type or ingredient is empty, inform the user to enter correct values