Guest User

Untitled

a guest
Nov 23rd, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Tue Nov 21 14:18:43 2017
  4.  
  5. @author: ptempone
  6. """
  7.  
  8. import ijson
  9. # =============================================================================
  10. # levanto el archivo
  11. # =============================================================================
  12. filename = "yasp_sample.json"
  13.  
  14. with open(filename, 'r', encoding="utf8") as f:
  15. objects = ijson.items(f, 'item.match_id')
  16. columns = list(objects)
  17.  
  18. filename = "sample_resumido.json"
  19. with open(filename, 'r', encoding="utf8") as f:
  20. #objects = ijson.items(f, '.radiant_win.item')
  21. #columns = list(objects)
  22. match_id = 0
  23. parser = ijson.parse(f)
  24. ret = {'match_id': {}}
  25. with open("salida.txt", "w") as text_file:
  26. for prefix, event, value in parser:
  27. print(prefix)
  28. #print(event)
  29. #print(value)
  30. #match_id =+ 1
  31. #if match_id >1:
  32. text_file.writelines("prefix: {0} \n".format(prefix))
  33.  
  34.  
  35. if (prefix, event) == ('item.match_id', 'map_key'):
  36. match_id = value
  37. ret['match_id'][match_id] = {}
  38. #elif prefix.endswith('.match_id'):
  39. #ret['match_id'][match_id]['match_id'] = value
Add Comment
Please, Sign In to add comment