Metadata-Version: 1.1
Name: NewlineJSON
Version: 0.1.0
Summary: Newline delimited JSON I/O that is hot swappable with csv.DictReader/Writer
Home-page: https://github.com/geowurster/NewlineJSON
Author: Kevin Wurster
Author-email: wursterk@gmail.com
License: New BSD License

Copyright (c) 2014, Kevin D. Wurster
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

* The names of its contributors may not be used to endorse or promote products
  derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Description: NewlineJSON
        ===========
        
        Currently under development.
        
        Streaming newline delimited JSON I/O
        
        [![Build Status](https://travis-ci.org/geowurster/NewlineJSON.svg)](https://travis-ci.org/geowurster/NewlineJSON)
        
        
        Overview
        --------
        
        Read and write files with a single JSON object on every line.  See the
        `sample-data` directory for valid input examples.
        
        One dictionary per line:
            
            >>> import newlinejson
            >>> with open('sample-data/dictionaries.json') as f:
            >>>     for line in newlinejson.Reader(f):
            >>>         print(line)
            >>>
            {'field2': 'l1f2', 'field3': 'l1f3', 'field1': 'l1f1'}
            {'field2': 'l2f2', 'field3': 'l3f3', 'field1': 'l2f1'}
            {'field2': 'l3f2', 'field3': 'l3f3', 'field1': 'l3f1'}
            {'field2': 'l4f2', 'field3': 'l4f3', 'field1': 'l4f1'}
            {'field2': 'l5f2', 'field3': 'l5f3', 'field1': 'l5f1'}
        
        One list per line:
        
            >>> import newlinejson
            >>> with open('sample-data/lists-no-header.json') as f:
            >>>     for line in newlinejson.Reader(f):
            >>>         print(line)
            >>>
            ['l1f2', 'l1f3', 'l1f1']
            ['l2f2', 'l3f3', 'l2f1']
            ['l3f2', 'l3f3', 'l3f1']
            ['l4f2', 'l4f3', 'l4f1']
            ['l5f2', 'l5f3', 'l5f1']
        
        Mixed content:
        
            >>> import newlinejson
            >>> with open('sample-data/mixed-content.json') as f:
            >>>     for line in newlinejson.Reader(f):
            >>>         print(line)
            >>> 
            {'field2': 'l1f2', 'field3': 'l1f3', 'field1': 'l1f1'}
            ['l1f2', 'l1f3', 'l1f1']
            {'field2': 'l2f2', 'field3': 'l3f3', 'field1': 'l2f1'}
            ['l2f2', 'l3f3', 'l2f1']
            {'field2': 'l3f2', 'field3': 'l3f3', 'field1': 'l3f1'}
            ['l3f2', 'l3f3', 'l3f1']
            {'field2': 'l4f2', 'field3': 'l4f3', 'field1': 'l4f1'}
            ['l4f2', 'l4f3', 'l4f1']
            {'field2': 'l5f2', 'field3': 'l5f3', 'field1': 'l5f1'}
            ['l5f2', 'l5f3', 'l5f1']
        
        The standard JSON functions `load/s()` and `dump/s()` are still available but
        should ONLY be used on small files and are really only included as a convenience.
        The `load/s()` functions return lists of JSON objects and `dump/s()`take the
        same format.
        
        Load from a file:
        
            >>> import newlinejson
            >>> with open('sample-data/dictionaries.json') as f:
            >>>     print(newlinejson.load(f))
            >>> 
            [
                {'field2': 'l1f2', 'field3': 'l1f3', 'field1': 'l1f1'},
                {'field2': 'l2f2', 'field3': 'l3f3', 'field1': 'l2f1'},
                {'field2': 'l3f2', 'field3': 'l3f3', 'field1': 'l3f1'},
                {'field2': 'l4f2', 'field3': 'l4f3', 'field1': 'l4f1'},
                {'field2': 'l5f2', 'field3': 'l5f3', 'field1': 'l5f1'}
            ]
        
        Load from a string:
        
            >>> import newlinejson
            >>> with open('sample-data/dictionaries.json') as f:
            >>>     print(newlinejson.loads(f.read()))
            >>> 
            [
                {'field2': 'l1f2', 'field3': 'l1f3', 'field1': 'l1f1'},
                {'field2': 'l2f2', 'field3': 'l3f3', 'field1': 'l2f1'},
                {'field2': 'l3f2', 'field3': 'l3f3', 'field1': 'l3f1'},
                {'field2': 'l4f2', 'field3': 'l4f3', 'field1': 'l4f1'},
                {'field2': 'l5f2', 'field3': 'l5f3', 'field1': 'l5f1'}
            ]
        
        Dump to a file:
            
            >>> with open('output.json', 'w') as f:
            >>>     newlinejson.dump(json_lines, f)
        
        Dump to a string:
            
            >>> string = newlinejson.dumps(json_lines)
        
        
        Installing
        ----------
        
            $ pip install newlinejson
        
        
        Developing
        ----------
            
            $ pip install virtualenv
            $ git clone https://github.com/geowurster/NewlineJSON
            $ cd NewlineJSON
            $ virtualenv venv
            $ source venv/bin/activate
            $ pip install -r requirements.txt -r requirements-dev.txt
            $ nosetests
        
        
        Testing
        -------
        
        Code coverage report
        
            $ nosetests \
            $     --with-coverage \
            $     --cover-package=newlinejson \
            $     --cover-erase --cover-inclusive
        
        PEP8 report - the default style guide is used except a max line length of 120
        is preferred.
        
            $ pep8 --max-line-length=120 newlinejson
Keywords: streaming newline json
Platform: UNKNOWN
Classifier: Topic :: Utilities
Classifier: Intended Audience :: Developers
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
