desdemona

better_freq_reducer

Jun 8th, 2016
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import sys
  4. import string
  5.  
  6.  
  7. def read_input(file, separator='\t'):
  8.     for line in file:
  9.         line.replace('\'', '').replace('[', '').replace(']', '').replace(',', '').replace(' ','\t')
  10.         yield line.rstrip().split(separator)
  11.  
  12. def main():
  13.  
  14.     ascii_letters = set(string.ascii_letters)
  15.     data = read_input(sys.stdin)
  16.  
  17.     for line in data:
  18.         key = line[0].strip()
  19.  
  20.         try:
  21.             value = line[1].strip()
  22.         except:
  23.             value = "_error_"
  24.  
  25.         print '%s\t%s' % (key, value)
  26.  
  27. if __name__ == "__main__":
  28.     main()
Add Comment
Please, Sign In to add comment