Nov-03-2023, 03:55 PM
i have the following function:
my_list=save_ent() new_list=[] for ent in my_list: new_list.append(output_found_flights(ent)) try: data_file=pd.read_csv("flight_data.csv") data_dict=data_file.to_dict(orient="records") except pandas.errors.EmptyDataError: messagebox.showerror(title="Oooops",message="There are no saved information") data_dict=[] finally: for ent in new_list: data_dict.append(ent) try: for i,ent in enumerate(data_dict): res= not all (ent.values()) if str(res): data_dict.pop(i) except AttributeError: data_dict.pop(i) finally: new_data_file=pd.DataFrame(data_dict) new_data_file.to_csv("flight_data.csv",index=False)the problem is the first time i run the code it executes correctly. When i try to add more search results it overwrites the csv file as expected but it gets rid of the previous search result and replaces it with the following
Output:0
""