test.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import json
  2. with open("pool_.txt", encoding="utf-8") as f:
  3. data = f.readlines()
  4. L = {}
  5. for line in data[1:]:
  6. line = line.strip().split("\t")
  7. # print(line)
  8. gh_id = line[3]
  9. position = line[5]
  10. account_level = line[-2]
  11. if account_level == "一级":
  12. acc_l = "1"
  13. elif account_level == "二级":
  14. acc_l = "2"
  15. elif account_level == "三级":
  16. acc_l = "3"
  17. else:
  18. continue
  19. key = "{}_{}".format(gh_id, position)
  20. print(gh_id, position, account_level)
  21. L[key] = acc_l
  22. # account_name = line[0]
  23. # gh_id = line[1]
  24. # fans = int(line[2])
  25. # level = line[3]
  26. # read_avg = float(line[4])
  27. # like_avg = float(line[5])
  28. # key = "{}_{}".format(gh_id, level)
  29. # obj = {
  30. # "accountName": account_name,
  31. # "ghId": gh_id,
  32. # "fans": fans,
  33. # "position": level,
  34. # "readAvg": read_avg,
  35. # "likeAvg": like_avg
  36. # }
  37. # L[key] = obj
  38. #
  39. with open("pool_detail.json", "w", encoding="utf-8") as f:
  40. f.write(json.dumps(L, ensure_ascii=False, indent=4))