Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import sys
  3. from collections import OrderedDict
  4.  
  5. def main(argv):
  6.     with open(argv[1], 'r') as f:
  7.         d = dict()
  8.         for line in f:
  9.             l = line.strip().split('|')
  10.             if l[0] in d:
  11.                 d[l[0]][l[1].strip()] = l[2]
  12.             else:
  13.                 d[l[0]] = {l[1].strip():l[2]}
  14.  
  15.         for key in d:
  16.             l = sorted(d[key].keys())
  17.             print d[key][l[0]], d[key][l[1]], d[key][l[2]]
  18.  
  19. if __name__ == '__main__':
  20.     main(sys.argv)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement