Iterate over the file, loading each line as JSON in the loop:

tweets = []
with open('tweets.json', 'r') as file:
    for line in file:
        tweets.append(json.loads(line))

This avoids storing intermediate python objects. As long as you write one full tweet per append() call, this should work.

Answer from Adam Hughes on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › json.decoder.jsondecodeerror: extra data ||| while trying to read .json file
r/learnpython on Reddit: json.decoder.JSONDecodeError: Extra data ||| While trying to read .json file
January 13, 2021 -

I have this json file that has this content:

{

"Instagram": {

"Social": "Instagram",

"E-Mail": "prova123@gmail.com",

"Password": "passw1234"

},

"Facebook": {

"Social": "Facebook",

"E-Mail": "ctry1231",

"Password": "ctry123"

}

}{

"Instagram": {

"Social": "Instagram",

"E-Mail": "prova123@gmail.com",

"Password": "passw1234"

},

"Facebook": {

"Social": "Facebook",

"E-Mail": "ctry1231",

"Password": "ctry123"

}

}

(this a try, after that all values will be the various under one "Manager").

But when i try to read it with json.load, i have this error:

json.decoder.JSONDecodeError: Extra data: line 14 column 2 (char 320)

like the problem appens if i try to add multiple dictionaries.. i can use json.load without any problem by having only one dictionary in the file

what can i do guys?

Discussions

Bug: `JSONDecodeError` when trying to load JSON with an array at the top-level
File "/tmp/archivebox/venv/lib.../decoder.py", line 340, in decode raise JSONDecodeError("Extra data", s, end) json.decoder.JSONDecodeError: Extra data: line 1 column 61 (char 60) The error is caused by the following line, introduced by commit aaca74f:... More on github.com
🌐 github.com
7
February 15, 2024
python - json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 190) - Stack Overflow
The example will give a different error. 2023-02-04T08:23:21.46Z+00:00 ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... New site design and philosophy for Stack Overflow: Starting February 24, 2026... 240 Python json.loads shows ValueError: Extra data... More on stackoverflow.com
🌐 stackoverflow.com
[Bug]: JSONDecodeError: Extra data: line 1 column 4 (char 3) on download_llama_dataset for PaulGrahamEssay
Bug Description Bug I had a public notebook that i created for public rag benchmarking. it was working perfectly fine with v0.10.11 but now i am getting on download_llama_dataset JSONDecodeError: E... More on github.com
🌐 github.com
1
April 25, 2024
Hello, i need help with the code. I need read code of JSON, but I have a problem
But i get this error: Traceback (most recent call last): File “c:\Users\aquiroz\OneDrive - Unified Networks\Documentos\adi VS\jsob.py”, line 14, in set_datos = json.load(contenido) ^^^^^^^^^^^^^^^^^^^^ File “C:\Users\aquiroz\AppData\Local\Programs\Python\Python312\Lib\json_init_.py”, ... More on discuss.python.org
🌐 discuss.python.org
0
0
December 16, 2023
🌐
Bobby Hadz
bobbyhadz.com › blog › python-jsondecodeerror-extra-data
json.decoder.JSONDecodeError: Extra data in Python [Solved] | bobbyhadz
April 8, 2024 - The Python "json.decoder.JSONDecodeError: Extra data" occurs when we try to parse multiple objects without wrapping them in an array. To solve the error, wrap the JSON objects in an array or declare a new property that points to an array value ...
🌐
GitHub
github.com › ArchiveBox › ArchiveBox › issues › 1347
Bug: `JSONDecodeError` when trying to load JSON with an array at the top-level · Issue #1347 · ArchiveBox/ArchiveBox
February 15, 2024 - File "/tmp/archivebox/venv/lib.../decoder.py", line 340, in decode raise JSONDecodeError("Extra data", s, end) json.decoder.JSONDecodeError: Extra data: line 1 column 61 (char 60) The error is caused by the following line, introduced by commit aaca74f:...
Author   philippemilink
🌐
GitHub
github.com › run-llama › llama_index › issues › 13114
[Bug]: JSONDecodeError: Extra data: line 1 column 4 (char 3) on download_llama_dataset for PaulGrahamEssay · Issue #13114 · run-llama/llama_index
April 25, 2024 - Bug Description Bug I had a public notebook that i created for public rag benchmarking. it was working perfectly fine with v0.10.11 but now i am getting on download_llama_dataset JSONDecodeError: Extra data: line 1 column 4 (char 3) Exac...
Author   authentichamza
🌐
Medium
medium.com › bugs-that-bite › json-decoder-jsondecodeerror-extra-data-line-14-column-945-char-5957-7e65c1366b56
json.decoder.JSONDecodeError: Extra data: line 14 column 945 (char 5957) | by Teri Radichel | Bugs That Bite | Medium
February 13, 2024 - In my particular case I got this error because I had been concatenating two different json files into one array of items. Then I started testing just one of the files and forgot to add the extra element indicating the list name for the list of dictionaries I was parsing.
🌐
Python.org
discuss.python.org › python help
Hello, i need help with the code. I need read code of JSON, but I have a problem - Python Help - Discussions on Python.org
December 16, 2023 - with open(‘new_york_times.json’,mode=“+r”,encoding=“UTF-8”) as contenido: set_datos = json.load(contenido) df = pd.DataFrame.from_dict(set_datos) But i get this error: Traceback (most recent call last): File “c:\Users\aquiroz\OneDrive - Unified Networks\Documentos\adi VS\jsob.py”, line 14, in set_datos = json.load(contenido) ^^^^^^^^^^^^^^^^^^^^ File “C:\Users\aquiroz\AppData\Local\Programs\Python\Python312\Lib\json_init_.py”, line 293, in load return loads(fp.read(), ^^^^^^^^^^^^^^^^ ...
Find elsewhere
🌐
sebhastian
sebhastian.com › python-jsondecodeerror-extra-data
Python json.decoder.JSONDecodeError: Extra data | sebhastian
January 30, 2023 - Python shows json.decoder.JSONDecodeError: Extra data error message when you try to load JSON data with an invalid format.
🌐
Kaggle
kaggle.com › questions-and-answers › 290373
error reading json from txt file in python
Checking your browser before accessing www.kaggle.com · Click here if you are not automatically redirected after 5 seconds
🌐
GitHub
github.com › microsoft › semantic-kernel › issues › 1930
Python: json.decoder.JSONDecodeError: Extra data: line 7 column 1 (char 125) · Issue #1930 · microsoft/semantic-kernel
April 16, 2023 - Describe the bug A clear and concise description of what the bug is. When running the sample python hello world we get: json.decoder.JSONDecodeError: Extra data: line 7 column 1 (char 125) Exception has occurred: JSONDecodeError Extra da...
Author   ewitkon
🌐
GitHub
github.com › lushan88a › google_trans_new › issues › 36
json.decoder.JSONDecodeError: Extra data: line 1 column 300 (char 299) · Issue #36 · lushan88a/google_trans_new
March 30, 2021 - Translating anything fails with exception "json.decoder.JSONDecodeError: Extra data: line 1 column 300 (char 299)"
Author   njlester
🌐
Python.org
discuss.python.org › python help
Why i am receiving the below error message? - Python Help - Discussions on Python.org
July 9, 2021 - Python code: import json import csv with open("/Users/olicaluag/Desktop/capture_for_Oliver.txt") as file: data = jason.load(file) fname = “output.csv” with open(fname, “w”) as file: csv_file = csv.writer(file) csv_file.writerow([“Interface”, “Logs”, “Name”]) for item in data[“result”]: csv_file.writerow([item[‘interface’], item[‘logs’], item[‘name’]]) error message: Traceback (most recent call last): File “/Users/olicaluag/Desktop/Hello World1.py”, line 5, in data = jason.load(fil...
🌐
Red Hat
access.redhat.com › solutions › 5248431
overcloud deployment failing with "json.decoder.JSONDecodeError: Extra data: line 1 column 7 (char 6)" - Red Hat Customer Portal
Processing templates in the directory /tmp/tripleoclient-8jpt8_jh/tripleo-heat-templates Action tripleo.parameters.update execution failed: Error validating environment for plan viper: ERROR: Internal Error Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/heat/engine/parameters.py", line 455, in parse return jsonutils.loads(val) File "/usr/lib/python3.6/site-packages/oslo_serialization/jsonutils.py", line 264, in loads return json.loads(encodeutils.safe_decode(s, encoding), **kwargs) File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads return _default_decod
🌐
GitHub
github.com › elastic › elasticsearch-py › issues › 967
JSONDecodeError('Extra data: line 1 column ... · Issue #967 · elastic/elasticsearch-py
June 4, 2019 - Elastic search python client is version 6.3.1 I have a gunicorne flask app with 4 workers. I use gevents to search multiple indices in 'parallel'. From time to time, I get the JSONDecodeError('Extra data: line 1 column 98726 (char 98725)',)) error while pulling data from Elasticsearch.
Author   neo-logic
🌐
GitHub
github.com › chroma-core › chroma › issues › 3545
[Bug]: JSONDecodeError("Extra data", s, end) on embedding_functions.OllamaEmbeddingFunction · Issue #3545 · chroma-core/chroma
December 19, 2024 - Hi, I'm using this piece of code to create text embeddings and I get JSONDecodeError when I pass variable _content_data_units that it is an array of strings. I tried to run it with small data array and it don't fails. Also I tested all models you see in the if, and the behaviour is the same, manually it works, with this code, don't. If I parse same texts in OpenAIEmbeddingFunction and I have no error.
Author   blackhold