I wrote the following code that takes a column from a csv file, it then converts it into an integer and adds them all up. I have done this for only one file and I have around 80 files to apply the same code to.
import csv
from collections import defaultdict
columns = defaultdict(list)
with open('Team11BoM.csv') as f:
reader = csv.DictReader(f)
for row in reader:
for (k,v) in row.items():
if k not in columns:
columns[k] = list()
columns[k].append(v)
import pandas as pd
df = pd.read_csv("Team11BoM.csv")
b = list(df['Reported Price'])
a = list(df['Actual Price'])
for i in range(0, len(a)):
a[i] = int(float(a[i]))
v = sum(a)
print("the total actual cost(s) for team 11 is:", v)
for i in range(0, len(b)):
b[i] = int(float(b[i]))
h = sum(b)
print("the total reported price for team 11 is:", h)
it prints out the following:
the total actual cost(s) for team 11 is: 945
the total reported price for team 11 is: 707
I want it to print out:
the total actual cost(s) for *filename* is: *Total cost of that team*
the total reported price for *filename* is: *Total reported price of that team*
Is there any simple way to do this?
thanks, Irfan S.