Advertisement
Guest User

reducer2.py

a guest
Mar 16th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import sys
  4.  
  5. def read_mapper_output(file, separator='\t'):
  6.     for line in file:
  7.         yield line.rstrip().split(separator, 1)
  8.  
  9. def main(separator='\t'):
  10.     # Input comes from STDIN
  11.     data = read_mapper_output(sys.stdin, separator=separator)
  12.     # Extract the 10 first items
  13.     for i in range(10):
  14.         uri = data.next()
  15.         print "%s%s%s" % (uri[1], separator, uri[0])
  16.     for uri in data:
  17.         continue
  18.  
  19. if __name__ == "__main__":
  20.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement