neldelesndblogtagscontactresume
neldelesndblogtagscontactresume

2020 September 21stReading uploaded CSV in Pandas using Djangopandasdjango 

Open user-uploaded CSV in Pandas using Django.


import pandas as pd from ..models import InputCsv def calc_net(): model = InputCsv qs = model.objects.filter(attempted_for_processing=False) for object in qs: df = pd.read_csv(object.csv.path) print(df) print(df.columns) df["net_profit"] = df["bought"] - df["sold"] object.output_csv = df.to_csv("output.csv") object.save() calc_net()

Sources: