Giter Site home page Giter Site logo

json-to-csv-neo4j's Introduction

json-to-csv

Nested JSON to CSV Converter.

This python script converts valid, preformatted JSON to CSV which can be opened in excel and other similar applications. This script can handle nested json with multiple objects and arrays. Please see the explanation below and the sample files to understand how this works. It can handle non similar objects too. But, more the similarity of the objects, prettier the output.

Written in Python 2.7

Usage

python /path/to/json_to_csv.py node_name json_in_file_path csv_out_file_path 

Source Specification

The script expects the json to be given via a file containing

  • A valid JSON
  • The JSON can be an Array of node Object Ex:-
    {
        "node":[
            {
                "item_1":"value_11",
                "item_2":"value_12",
                "item_3":"value_13",
                "item_4":["sub_value_14", "sub_value_15"],
                "item_5":{
                    "sub_item_1":"sub_item_value_11",
                    "sub_item_2":["sub_item_value_12", "sub_item_value_13"]
                }
            },
            {
                "item_1":"value_21",
                "item_2":"value_22",
                "item_4":["sub_value_24", "sub_value_25"],
                "item_5":{
                    "sub_item_1":"sub_item_value_21",
                    "sub_item_2":["sub_item_value_22", "sub_item_value_23"]
                }
            }
        ]
    }
  • The JSON can be a list of dictionaries
    [
        {
            "item_1":"value_11",
            "item_2":"value_12",
            "item_3":"value_13",
            "item_4":["sub_value_14", "sub_value_15"],
            "item_5":{
                "sub_item_1":"sub_item_value_11",
                "sub_item_2":["sub_item_value_12", "sub_item_value_13"]
            }
        },
        {
            "item_1":"value_21",
            "item_2":"value_22",
            "item_4":["sub_value_24", "sub_value_25"],
            "item_5":{
                "sub_item_1":"sub_item_value_21",
                "sub_item_2":["sub_item_value_22", "sub_item_value_23"]
            }
        }
    ]
  • node_name can be any relevant string if the JSON is a list of dictionaries

Gotchas

I have written a JSON generator which will take care of encoding issues and generate a valid JSON for this tool. However, If you find yourself in the character encoding hell, drop me a mail and I will add support for this This is now fixed.

Read More

Visit http://askvinay.com/#post?Converting-Nested-JSON-to-CSV to read more about this script.

json-to-csv-neo4j's People

Contributors

vinay20045 avatar zrg1993 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.