If I understands your question correctly, I think this will solve it:

with jsonlines.open('yourTextFile', mode='a') as writer:
    writer.write(...)

As you mentioned you are overwriting the file, I think this is because you use mode='w' (w = writing) instead of using mode='a' (a = appending)

Answer from Jeppe Spanggaard on Stack Overflow
🌐
Readthedocs
jsonlines.readthedocs.io
jsonlines — jsonlines documentation
jsonlines is a Python library to simplify working with jsonlines and ndjson data.
🌐
PyPI
pypi.org › project › jsonlines
jsonlines · PyPI
Download URL: jsonlines-4.0.0-py3-none-any.whl · Upload date: Sep 1, 2023 · Size: 8.7 kB · Tags: Python 3 · Uploaded using Trusted Publishing? No · Uploaded via: twine/4.0.2 CPython/3.11.5 · See more details on using hashes here. Supported by ·
      » pip install jsonlines
    
Published   Sep 01, 2023
Version   4.0.0
Discussions

Python: How to write jsonline without overwriting? - Stack Overflow
I have a piece of code, it process thousands of files in a directory, for each file, it generate an object (dictionary) with part of its key-value as: { ........ 'result': [...a very long ... More on stackoverflow.com
🌐 stackoverflow.com
python - How to load jsonlines file with simple file read - Stack Overflow
Consider having the following code and a jsonl file, there is a specific reason I don't read file with jsonlines.open() api, so please take this as a fact. Reference for jsonlines package: https:// More on stackoverflow.com
🌐 stackoverflow.com
python - Loading and parsing a JSON file with multiple JSON objects - Stack Overflow
see https://jsonlines.readthedocs.io/ ... Just like Martijn Pieters' answer but maybe a bit more pythonic, and most of all, which enables streaming of data (see second part of the answer): More on stackoverflow.com
🌐 stackoverflow.com
Reading a large (30.6G) JSONL file
There's no good off-the-shelf solution for this. JSON files are simply not designed for that. There's a couple of "lazy" json parsers or "iterative" parsers, but in the end it comes down to what your data looks like. It's often better / easier to parse out the higher objects yourself. For example if your data is a massive list of lists, you could manually search for the "[]" characters and pass the results into json.loads as a "stream". More on reddit.com
🌐 r/learnpython
14
5
April 21, 2021
People also ask

What is the best way to visualize JSONL data?
Row Zero is a good JSONL viewer because it opens JSONL files in a spreadsheet format that makes it easy to view, filter, analyze, and troubleshoot large datasets.
🌐
rowzero.com
rowzero.com › blog › open-jsonl-file-format
Easily Open JSONL Files - Guide to JSON Lines Format | Row Zero
Can you open JSONL in Excel?
No you cannot open JSONL in Excel directly. You can covert JSONL to CSV using a tool like Row Zero or Python and then open the CSV in Excel.
🌐
rowzero.com
rowzero.com › blog › open-jsonl-file-format
Easily Open JSONL Files - Guide to JSON Lines Format | Row Zero
Who uses JSONL files?
JSON Lines files are often used by data engineers, data scientists, and analysts because JSONL is good at processing and managing large datasets. JSONL is good for real-time data and streaming applications.
🌐
rowzero.com
rowzero.com › blog › open-jsonl-file-format
Easily Open JSONL Files - Guide to JSON Lines Format | Row Zero
🌐
GitHub
github.com › wbolster › jsonlines
GitHub - wbolster/jsonlines: python library to simplify working with jsonlines and ndjson data
jsonlines is a Python library to simplify working with jsonlines and ndjson data.
Starred by 307 users
Forked by 31 users
Languages   Python
🌐
Jsonlines
jsonlines.org
JSON Lines
This page describes the JSON Lines text format, also called newline-delimited JSON. JSON Lines is a convenient format for storing structured data that may be processed one record at a time. It works well with unix-style text processing tools and shell pipelines.
Find elsewhere
🌐
Medium
nicholaszhan.com › line-em-up-a-guide-to-json-lines-7c43215b3b82
Line ’Em Up: A Guide to JSON Lines | by Nicholas Zhan | Medium
February 2, 2024 - # Reading from a JSON Lines file with open('sensor_data.jsonl', 'r') as file: for line in file: data_entry = json.loads(line) # Process each data_entry as a Python dict print(data_entry)
🌐
Rowzero
rowzero.com › blog › open-jsonl-file-format
Easily Open JSONL Files - Guide to JSON Lines Format | Row Zero
October 24, 2024 - Here's example Python code: import json import jsonlines # Load the JSON file with open('data.json', 'r') as f: data = json.load(f) # Write to a JSONL file with jsonlines.open('data.jsonl', mode='w') as writer: for obj in data: writer.write(obj)
🌐
Arch Linux
archlinux.org › packages › extra › any › python-jsonlines
Arch Linux - python-jsonlines 4.0.0-5 (any)
View the file list for python-jsonlines · View the soname list for python-jsonlines · Copyright © 2002-2026 Judd Vinet, Aaron Griffin and Levente Polyák. The Arch Linux name and logo are recognized trademarks. Some rights reserved.
🌐
Jsonlines
jsonlines.org › examples
JSON Lines |Examples
CSV seems so easy that many programmers have written code to generate it themselves, and almost every implementation is different. Handling broken CSV files is a common and frustrating task. CSV has no standard encoding, no standard column separator and multiple character escaping standards.
🌐
PyPI
pypi.org › project › json-lines
json-lines · PyPI
Reading JSON lines (jl) files, recover broken files
      » pip install json-lines
    
Published   Nov 21, 2018
Version   0.5.0
🌐
Langchain
js.langchain.com › docs › integrations › document_loaders › file_loaders › jsonlines
JSONLines files
This example goes over how to load data from JSONLines or JSONL files. The second argument is a JSONPointer to the property to extract from each JSON object in the file. One document will be created for each JSON object in the file.
🌐
Reddit
reddit.com › r/learnpython › faster way to process jsonl file with thousands of json lines
r/learnpython on Reddit: Faster way to process JSONL file with thousands of json lines
July 21, 2023 -

Hello, As the title, I have thousands to millions json lines spread over multiple JSONL format files.
What would be an efficient approach to process those lines and store in a temporary object that I want to index to some application?
Currently I'm thinking to process N lines per batch, index them and repeat until the last line in last file.

🌐
Arch Linux ARM
archlinuxarm.org › packages › aarch64 › python-jsonlines
python-jsonlines (aarch64) | Packages | Arch Linux ARM
Copyright ©2009-2026 Arch Linux ARM The registered trademark Linux® is used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a world-wide basis. The Arch Linux™ name and logo are used under permission of the Arch Linux Project Lead
🌐
DEV Community
dev.to › scrapfly_dev › jsonl-vs-json-hb0
JSONL vs JSON - DEV Community
December 17, 2024 - With the jsonlines library, Python makes handling JSONLines straightforward.
🌐
Debian
packages.debian.org › unstable › python › python3-jsonlines
Details of package python3-jsonlines in sid
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser