how to clean a JSON file and store it to another file in Python -


i trying read json file python. file described authors not strict json. in order convert strict json, suggest approach:

import json  def parse(path):     g = gzip.open(path, 'r')     l in g:         yield json.dumps(eval(l)) 

however, not being familiar python, able execute script not able produce output file new clean json. how should modify script in order produce new json file? have tried this:

import json  class amazon():      def parse(self, inpath, outpath):         g = open(inpath, 'r')         out = open(outpath, 'w')         l in g:             yield json.dumps(eval(l), out)  amazon = amazon() amazon.parse("original.json", "cleaned.json") 

but output empty file. more welcome

import json  class amazon():      def parse(self, inpath, outpath):         g = open(inpath, 'r')         open(outpath, 'w') fout:             l in g:                 fout.write(json.dumps(eval(l)))  amazon = amazon() amazon.parse("original.json", "cleaned.json") 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -