Skip to content

Instantly share code, notes, and snippets.

@okaram
Last active August 29, 2015 14:05
Show Gist options
  • Save okaram/66e85c2b08d1fbd79c53 to your computer and use it in GitHub Desktop.
Save okaram/66e85c2b08d1fbd79c53 to your computer and use it in GitHub Desktop.
sales=sc.textFile("sales_*.txt").map(lambda x:x.split('\t'))
2014-01-01 1 1 100
2014-01-01 1 2 37
2014-01-01 1 3 54
2014-01-01 2 1 50
2014-01-01 2 2 40
2014-01-01 3 1 75
sales_by_product=sales.map(lambda x : (x[0],int(x[2])) ).reduceByKey(lambda x,y:x+y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment