Created
February 6, 2018 09:34
-
-
Save koushikmln/4aecd0c739ca5c75a451fdbf0bcf718d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import reduce | |
def getTotalById(order_items,id): | |
filtered_list = filter(lambda x: int(x.split(",")[1]) == id,order_items) | |
subtotal = map(lambda x: float(x.split(",")[4]), filtered_list) | |
return reduce(lambda x,y: x + y,subtotal) | |
order_items = open("/data/retail_db/order_items/part-00000","r").read().splitlines() | |
getTotalById(order_items[:20],5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment