Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- all_shows_views = []
- shows_on_ABC = []
- for line in sys.stdin:
- line = line.strip() #strip out carriage return (i.e. removes line breaks).
- key_value = line.split(",") #split line into key and value, returns a list.
- key_in = key_value[0] #.split(" ") - Dont need the split(" ") b/c there is no date.
- value_in = key_value[1] #value is 2nd item.
- if value_in.isdigit():
- show = key_in
- all_shows_views.append(show + "\t" + value_in)
- if value_in == "ABC": #check if the TV Show is ABC.
- show = key_in
- shows_on_ABC.append(show)
- for i in range(len(all_shows_views)):
- show_view = all_shows_views[i].split("\t")
- for c in range(len(shows_on_ABC)):
- if show_view[0] == shows_on_ABC[c]:
- print (show_view[0] + "\t" + show_view[1])
- #Note that Hadoop expects a tab to separate key value
- #but this program assumes the input file has a ',' separating key value.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement