Sample table of data
import csv
f = open('C:\\Users\\keshabg\\Desktop\\sql_testing\\table_1.csv')
csv_f = csv.reader(f)
def try1(data,process,shift,lc):
result = []
if data == 'units':
result_column = 5
elif data == 'hours':
result_column = 6
else:
raise NotImplementedError
for row in csv_f:
if row[2] == shift and row[3] == process and row[4] == lc:
result.append(row[result_column])
return result
if __name__=="__try1__":
try1()
I have this function that's returning units and hours according to process, shift and level depending on whether the data type is units or data type is hours. How would I make a second function that calculates the rate which is units/hours according to process, shift and level depending on that data type which uses the first function as well.