You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
746 B
24 lines
746 B
import csv
|
|
from itertools import zip_longest
|
|
from file_handling import read_csv
|
|
import pandas as pd
|
|
|
|
|
|
def add_list_to_empty_csv(file, set_list):
|
|
rows = zip_longest(*set_list, fillvalue="")
|
|
with open(file, "w", encoding="ISO-8859-1", newline='') as file:
|
|
writer = csv.writer(file)
|
|
writer.writerows(rows)
|
|
file.close()
|
|
|
|
|
|
def add_df_to_empty_csv(file, setlist_df):
|
|
setlist_df.to_csv(file, index=False)
|
|
|
|
|
|
def append_df_csv(file, setlist_df):
|
|
csv_list = read_csv.return_csv_as_df(file)
|
|
setlist_df["Quantity"] = setlist_df["Quantity"].astype(int)
|
|
df = pd.concat([csv_list, setlist_df]).groupby(["Part number", "Name"], as_index=False)["Quantity"].sum()
|
|
df.to_csv(file, index=False)
|