Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import sys
  3.  
  4. all_shows_views = []
  5. shows_on_ABC = []
  6.  
  7. for line in sys.stdin:
  8. line = line.strip() #strip out carriage return (i.e. removes line breaks).
  9. key_value = line.split(",") #split line into key and value, returns a list.
  10. key_in = key_value[0] #.split(" ") - Dont need the split(" ") b/c there is no date.
  11. value_in = key_value[1] #value is 2nd item.
  12.  
  13. if value_in.isdigit():
  14. show = key_in
  15. all_shows_views.append(show + "\t" + value_in)
  16. if value_in == "ABC": #check if the TV Show is ABC.
  17. show = key_in
  18. shows_on_ABC.append(show)
  19.  
  20. for i in range(len(all_shows_views)):
  21. show_view = all_shows_views[i].split("\t")
  22. for c in range(len(shows_on_ABC)):
  23. if show_view[0] == shows_on_ABC[c]:
  24. print (show_view[0] + "\t" + show_view[1])
  25.  
  26. #Note that Hadoop expects a tab to separate key value
  27. #but this program assumes the input file has a ',' separating key value.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement