Ejemplo n.º 1
0
        reader = csv.DictReader(fi)
        for row in reader:
            yield(row)


# Now get the stream of data and process it


input_file = sys.argv[1]
out_file = sys.argv[2]
individual_cart = set()
for hod in salesRead(input_file):  
    product_id = hod['Product ID']
    customer_id = hod['Customer ID']
    item_cost = hod['Item Cost']
    itemRevenue.put(product_id,float(item_cost))
    if(currentCustomer != customer_id):
        individual_cart = set()
    elif (product_id in individual_cart):
        continue
    individual_cart.add(product_id)
    item_set.add(product_id)
    itemCount.put(product_id,1)
    currentCustomer = customer_id
    


#  Now Write the stream data to file


header = [['Product ID','Customer Count','Total Revenue']]