This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

This is a tiny library for reading JSON lines (.jl) files, including gzipped and broken files.

JSON lines is a text file format where each line is a single json encoded item.

Why?

Reading a well-formed JSON lines file is a one-liner in Python. But if the file can be broken (this happens when the process writing it is killed), handling all exceptions takes 10x more code, especially when the file is compressed.

Installation

pip install json-lines

Usage

In order to read a well-formed json lined file, pass an open file as the first argument to json_lines.reader. The file can be opened in text or binary mode, but if it’s opened in text mode, the encoding must be set correctly:

import json_lines

with open('file.jl', 'rb') as f:
    for item in json_lines.reader(f):
        print(item['x'])

There is also a helper function json_lines.open that recognizes “.gz” and “.gzip” extensions and opens them with gzip:

with json_lines.open('file.jl.gz') as f:
    for item in f:
        print(item['x'])

Handling broken (cut at some point) files is enabled by passing broken=True to json_lines.reader or json_lines.open. They are read while it’s possible to decode the compressed stream and parse json, silently stopping on the first error (only logging a warning):

with json_lines.open('file.jl.gz', broken=True) as f:
    for item in f:
        print(item['x'])

License

License is MIT.

Release History

Release History

0.2.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
json_lines-0.2.0-py2.py3-none-any.whl (4.3 kB) Copy SHA256 Checksum SHA256 3.5 Wheel Sep 6, 2016
json-lines-0.2.0.tar.gz (2.5 kB) Copy SHA256 Checksum SHA256 Source Sep 6, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting