title: read a file with a stream of json objects in python
body: <p>This may be redundant, but after reading previous posts and answers I still have not gotten my code to work. I have a very large file containing multiple json objects that are not delimited by any values:</p>
  
  <blockquote>
    <blockquote>
      <p>{"_index": "1234", "_type": "11", "_id": "1234", "_score": 0.0, "fields": {"c_u": ["url.com"], "tawgs.id": ["p6427"]}}{"_index": "1234", "_type": "11", "_id": "786fd4ad2415aa7b", "_score": 0.0, "fields": {"c_u": ["url2.com"], "tawgs.id": ["p12519"]}}{"_index": "1234", "_type": "11", "_id": "5826e7cbd92d951a", "_score": 0.0, "fields": {"tawgs.id": ["p8453", "p8458"]}}</p>
    </blockquote>
  </blockquote>
  
  <p>I've read that this is exactly what JSON-RPC is supposed to look like, but still can't achieve opening/parsing the file to create a dataframe in python.</p>
  
  <p>I tried something of the format of:</p>
  
  <pre><code>i = 0
  d = json.JSONDecoder()
  while True:
      try:
          obj, i = d.raw_decode(s, i)
      except ValueError:
          return
      yield obj
  </code></pre>
  
  <p>but it didn't work. </p>
  
  <p>I've also tried a basic:</p>
  
  <pre><code>with open('output.json','r') as f:
      data = json.load(f)
  </code></pre>
  
  <p>but am thrown the error:</p>
  
  <blockquote>
    <blockquote>
      <p>JSONDecodeError: Extra data: line 1 column 184 (char 183) </p>
    </blockquote>
  </blockquote>
  
  <p>Trying json.decode() with append didn't work either and returned data empty []</p>
  
  <pre><code>data = []
  with open('es-output.json', 'r') as f:
      for line in f:
          try:
              data.append(json.loads(line))
          except json.decoder.JSONDecodeError:
              pass # skip this line 
  </code></pre>
  
  <p>Please help! Thanks in advance</p>