mvanveen / Decantor

JSON to CSV conversion tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Decantor: A JSON To CSV Conversion Tool
# -----------------------------------------------------------------------------
  Authors:
    - Michael Van Veen
  Date: 1/28/11
# -----------------------------------------------------------------------------

Description: |
# -----------------------------------------------------------------------------
Accountants of the world, rejoice!  Watch in awe as sophisticated, recursive
tree structures flatten with ease.  Decantor is a tool to convert a list of 
arbitrary JSON objects ino an equivalent matrix/spreadsheet representation.

Currently only works on javascript arrays of json objects, due to the python
json library's predilection towards exporting them.

Example Usage: |
# -----------------------------------------------------------------------------
python decantor.py <json input> <csv output>

Changelog: 
# -----------------------------------------------------------------------------
  - 3/2/11 : Scrubs empty columns from output.  Added some doctests.
             CSV formatting disregards newlines and escapes everything.

TODOS:
# -----------------------------------------------------------------------------
- Implement tests.  Fuzz testing could be neat.
- Support for other JSON list formats (newline seperated, MongoDB, etc.)
- Support for XML. (XML -> JSON -> CSV)


License: |
# -----------------------------------------------------------------------------
  The MIT License
 
  Copyright (c) 2011, Michael Van Veen, and Gettaround, Inc.
 
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
  
  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE

About

JSON to CSV conversion tool


Languages

Language:Python 100.0%