Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Tue Nov 21 14:18:43 2017
- @author: ptempone
- """
- import ijson
- # =============================================================================
- # levanto el archivo
- # =============================================================================
- filename = "yasp_sample.json"
- with open(filename, 'r', encoding="utf8") as f:
- objects = ijson.items(f, 'item.match_id')
- columns = list(objects)
- filename = "sample_resumido.json"
- with open(filename, 'r', encoding="utf8") as f:
- #objects = ijson.items(f, '.radiant_win.item')
- #columns = list(objects)
- match_id = 0
- parser = ijson.parse(f)
- ret = {'match_id': {}}
- with open("salida.txt", "w") as text_file:
- for prefix, event, value in parser:
- print(prefix)
- #print(event)
- #print(value)
- #match_id =+ 1
- #if match_id >1:
- text_file.writelines("prefix: {0} \n".format(prefix))
- if (prefix, event) == ('item.match_id', 'map_key'):
- match_id = value
- ret['match_id'][match_id] = {}
- #elif prefix.endswith('.match_id'):
- #ret['match_id'][match_id]['match_id'] = value
Add Comment
Please, Sign In to add comment