0

Sample table of data

enter code here

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.

quamrana
  • 37,849
  • 12
  • 53
  • 71
  • 2
    I don't know what you think `if __name__=="__try1__"` does, but it doesn't. That will always be false. – zvone Nov 05 '19 at 16:04
  • for the moment its not doing anything – Keshab Gautam Nov 05 '19 at 16:08
  • Does this answer your question? [using the output of a function as the input in another function python new to coding](https://stackoverflow.com/questions/26049876/using-the-output-of-a-function-as-the-input-in-another-function-python-new-to-co) – G. Anderson Nov 05 '19 at 16:20
  • @G.Anderson i didnt understand that at all and part of the problem is its not formatted – Keshab Gautam Nov 05 '19 at 17:16

0 Answers0