Advertisement
Guest User

Untitled

a guest
Aug 20th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. #!/usr/bin/python
  2. import sys
  3. import csv
  4. import re
  5.  
  6. reader = csv.reader(sys.stdin, delimiter = "\t")
  7.  
  8. for line in reader:
  9. if len(line) == 19:
  10. title = line[1]
  11. tagnames = line [2]
  12. author_id = line[3]
  13. nodetype = line[5]
  14. parent_id = line[6]
  15. abs_parent_id = line[7]
  16. added_at = line[8]
  17. score = line[9]
  18. print "{0}\tB\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}".format(author_id,title,tagnames,nodetype,parent_id,abs_parent_id,added_at,score)
  19. if len(line) == 5:
  20. id = line[0]
  21. reputation = line[1]
  22. gold = line[2]
  23. silver = line[3]
  24. bronze = line[4]
  25. print "{0}\tA\t{1}\t{2}\t{3}\t{4}".format(id,reputation,gold,silver,bronze)
  26.  
  27.  
  28. import sys
  29. import csv
  30.  
  31. reader = csv.reader(sys.stdin, delimiter = "\t")
  32. reputation = None
  33. gold = None
  34. silver = None
  35. bronze = None
  36. title = None
  37. tagnames = None
  38. nodetype = None
  39. parent_id = None
  40. abs_parent_id = None
  41. added_at = None
  42. score = None
  43. oldId = None
  44.  
  45. for line in reader:
  46. id = line[0]
  47. #print "{0}\t{1}\t{2}".format(id, len(line), line[1])
  48. #if id and oldId != id:
  49. if line[1] == "A":
  50. #print "User data : {0}\t{1}\t{2}\t{3}".format(line[2], line[3], line[4], line[5])
  51. reputation = line[2]
  52. gold = line[3]
  53. silver = line[4]
  54. bronze = line[5]
  55. continue
  56. #if line[1] == "B":
  57. print "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}".format(id,line[2], line[3], line[4], line[5], line[6], line[7], line[8], reputation,gold,silver,bronze)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement