Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. def parse(file, store):
  2. f = open(file, 'r')
  3. dic = {}
  4. for i in f:
  5. i = i.strip("\n")
  6. val = i.split("\t")
  7. try:
  8. dic[val[0]] = dic[val[0]] + ","+ val[1]
  9. except KeyError:
  10. dic[val[0]] = val[1]
  11. f.close()
  12. f = open(store, 'w')
  13. for i in dic.keys():
  14. string = i+"\t"+dic[i]
  15. f.write(string+"\n")
  16. f.close
  17.  
  18. if __name__=="__main__":
  19. import sys
  20. if len(sys.argv) > 1:
  21. file = sys.argv[1]
  22. store = sys.argv[2]
  23. parse(file, store)
  24. else:
  25. sys.exit("No input")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement