Advertisement
Guest User

reducer2.py

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