title: how to clean a JSON file and store it to another file in Python
body: <p>I am trying to read a JSON file with Python. This file is described by the authors as not strict JSON. In order to convert it to strict JSON, they suggest this approach:</p>
  
  <pre><code>import json
  
  def parse(path):
      g = gzip.open(path, 'r')
      for l in g:
          yield json.dumps(eval(l))
  </code></pre>
  
  <p>however, not being familiar with Python, I am able to execute the script but I am not able to produce any output file with the new clean JSON. How should I modify the script in order to produce a new JSON file? I have tried this:</p>
  
  <pre><code>import json
  
  class Amazon():
  
      def parse(self, inpath, outpath):
          g = open(inpath, 'r')
          out = open(outpath, 'w')
          for l in g:
              yield json.dumps(eval(l), out)
  
  amazon = Amazon()
  amazon.parse("original.json", "cleaned.json")
  </code></pre>
  
  <p>but the output is an empty file. Any help more than welcome</p>