======
ndjson
======
Support for ndjson. Plain and simple.
.. image:: https://img.shields.io/pypi/v/ndjson.svg
:target: https://pypi.python.org/pypi/ndjson
.. image:: https://img.shields.io/travis/rhgrant10/ndjson.svg
:target: https://travis-ci.org/rhgrant10/ndjson
.. image:: https://img.shields.io/pypi/pyversions/ndjson
:target: https://pypi.python.org/pypi/ndjson
.. image:: https://img.shields.io/pypi/l/ndjson
:target: https://pypi.python.org/pypi/ndjson
Features
--------
* familiar interface
* very small
* no dependencies
* works as advertised
* has tests
Usage
-----
``ndjson`` exposes the same api as the builtin ``json`` and ``pickle`` packages.
.. code-block:: python
import ndjson
# load from file-like objects
with open('data.ndjson') as f:
data = ndjson.load(f)
# convert to and from objects
text = ndjson.dumps(data)
data = ndjson.loads(text)
# dump to file-like objects
with open('backup.ndjson', 'w') as f:
ndjson.dump(items, f)
It contains ``JSONEncoder`` and ``JSONDecoder`` classes for easy
use with other libraries, such as ``requests``:
.. code-block:: python
import ndjson
import requests
response = requests.get('https://example.com/api/data')
items = response.json(cls=ndjson.Decoder)
The library also packs ``reader`` and ``writer`` classes very similar to standard csv ones:
.. code-block:: python
import ndjson
# Streaming lines from ndjson file:
with open('./posts.ndjson') as f:
reader = ndjson.reader(f)
for post in reader:
print(post)
# Writing items to a ndjson file
with open('./posts.ndjson', 'w') as f:
writer = ndjson.writer(f, ensure_ascii=False)
for post in posts:
writer.writerow(post)
Credits
-------
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
=======
History
=======
0.3.1 (2020-02-24)
------------------
* Fix a small spelling mistake
0.3.0 (2020-02-24)
------------------
* Add ``ndjson.writer``
* Add ``ndjson.reader``
0.2.0 (2019-08-01)
------------------
* Add 3.7 support
* Remove 3.4 support
0.1.0 (2018-05-17)
------------------
* First release on PyPI.
Raw data
{
"_id": null,
"home_page": "https://github.com/rhgrant10/ndjson",
"name": "ndjson",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "ndjson",
"author": "Robert Grant",
"author_email": "rhgrant10@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/b4/d5/209b6ca94566f9c94c0ec41cee1681c0a3b92a306a84a9b0fcd662088dc3/ndjson-0.3.1.tar.gz",
"platform": "",
"description": "======\nndjson\n======\n\nSupport for ndjson. Plain and simple.\n\n.. image:: https://img.shields.io/pypi/v/ndjson.svg\n :target: https://pypi.python.org/pypi/ndjson\n\n.. image:: https://img.shields.io/travis/rhgrant10/ndjson.svg\n :target: https://travis-ci.org/rhgrant10/ndjson\n\n.. image:: https://img.shields.io/pypi/pyversions/ndjson\n :target: https://pypi.python.org/pypi/ndjson\n\n.. image:: https://img.shields.io/pypi/l/ndjson\n :target: https://pypi.python.org/pypi/ndjson\n\n\nFeatures\n--------\n\n* familiar interface\n* very small\n* no dependencies\n* works as advertised\n* has tests\n\n\nUsage\n-----\n\n``ndjson`` exposes the same api as the builtin ``json`` and ``pickle`` packages.\n\n.. code-block:: python\n\n import ndjson\n\n # load from file-like objects\n with open('data.ndjson') as f:\n data = ndjson.load(f)\n\n # convert to and from objects\n text = ndjson.dumps(data)\n data = ndjson.loads(text)\n\n # dump to file-like objects\n with open('backup.ndjson', 'w') as f:\n ndjson.dump(items, f)\n\n\nIt contains ``JSONEncoder`` and ``JSONDecoder`` classes for easy\nuse with other libraries, such as ``requests``:\n\n.. code-block:: python\n\n import ndjson\n import requests\n\n response = requests.get('https://example.com/api/data')\n items = response.json(cls=ndjson.Decoder)\n\nThe library also packs ``reader`` and ``writer`` classes very similar to standard csv ones:\n\n.. code-block:: python\n\n import ndjson\n\n # Streaming lines from ndjson file:\n with open('./posts.ndjson') as f:\n reader = ndjson.reader(f)\n\n for post in reader:\n print(post)\n\n # Writing items to a ndjson file\n with open('./posts.ndjson', 'w') as f:\n writer = ndjson.writer(f, ensure_ascii=False)\n\n for post in posts:\n writer.writerow(post)\n\n\nCredits\n-------\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n\n=======\nHistory\n=======\n\n0.3.1 (2020-02-24)\n------------------\n\n* Fix a small spelling mistake\n\n0.3.0 (2020-02-24)\n------------------\n\n* Add ``ndjson.writer``\n* Add ``ndjson.reader``\n\n0.2.0 (2019-08-01)\n------------------\n\n* Add 3.7 support\n* Remove 3.4 support\n\n0.1.0 (2018-05-17)\n------------------\n\n* First release on PyPI.\n\n\n",
"bugtrack_url": null,
"license": "GNU General Public License v3",
"summary": "JsonDecoder for ndjson",
"version": "0.3.1",
"split_keywords": [
"ndjson"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "c810fd9313ef733f386fcef8a30ec7d1",
"sha256": "839c22275e6baa3040077b83c005ac24199b94973309a8a1809be962c753a410"
},
"downloads": -1,
"filename": "ndjson-0.3.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "c810fd9313ef733f386fcef8a30ec7d1",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 5305,
"upload_time": "2020-02-25T05:01:06",
"upload_time_iso_8601": "2020-02-25T05:01:06.390104Z",
"url": "https://files.pythonhosted.org/packages/70/c9/04ba0056011ba96a58163ebfd666d8385300bd12da1afe661a5a147758d7/ndjson-0.3.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "631b36ea929a48c00fd00e1b1f6162eb",
"sha256": "bf9746cb6bb1cb53d172cda7f154c07c786d665ff28341e4e689b796b229e5d6"
},
"downloads": -1,
"filename": "ndjson-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "631b36ea929a48c00fd00e1b1f6162eb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6448,
"upload_time": "2020-02-25T05:01:07",
"upload_time_iso_8601": "2020-02-25T05:01:07.873737Z",
"url": "https://files.pythonhosted.org/packages/b4/d5/209b6ca94566f9c94c0ec41cee1681c0a3b92a306a84a9b0fcd662088dc3/ndjson-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-02-25 05:01:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "rhgrant10",
"github_project": "ndjson",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "ndjson"
}