Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 12th, 2012  |  syntax: Python  |  size: 0.32 KB  |  views: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import sys
  2. from collections import defaultdict
  3.  
  4. fname = sys.argv[1]
  5. with open(fname) as fin:
  6.     data = defaultdict(list)  
  7.     for line in fin:
  8.         x,y = line.split()
  9.         data[int(x)].append(float(y))
  10.  
  11. for k,v in sorted(data.items()):
  12.     for i,elem in enumerate(v):
  13.         print i,elem
  14.     print
  15.     print
clone this paste RAW Paste Data