All Projects β†’ alingse β†’ Jsoncsv

alingse / Jsoncsv

Licence: apache-2.0
a command tool easily convert json file to csv or xlsx

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Jsoncsv

Sqlitebiter
A CLI tool to convert CSV / Excel / HTML / JSON / Jupyter Notebook / LDJSON / LTSV / Markdown / SQLite / SSV / TSV / Google-Sheets to a SQLite database file.
Stars: ✭ 601 (+1297.67%)
Mutual labels:  json, csv
Sheetjs
πŸ“— SheetJS Community Edition -- Spreadsheet Data Toolkit
Stars: ✭ 28,479 (+66130.23%)
Mutual labels:  json, csv
Fsharp.data
F# Data: Library for Data Access
Stars: ✭ 631 (+1367.44%)
Mutual labels:  json, csv
Goloc
A flexible tool for application localization using Google Sheets.
Stars: ✭ 42 (-2.33%)
Mutual labels:  json, csv
Kalulu
Uganda Elections Tools and Resources
Stars: ✭ 24 (-44.19%)
Mutual labels:  json, csv
World countries
Constantly updated lists of world countries and their associated alpha-2, alpha-3 and numeric country codes as defined by the ISO 3166 standard, available in CSV, JSON , PHP and SQL formats, in multiple languages and with national flags included
Stars: ✭ 598 (+1290.7%)
Mutual labels:  json, csv
Structured Text Tools
A list of command line tools for manipulating structured text data
Stars: ✭ 6,180 (+14272.09%)
Mutual labels:  json, csv
Datasette
An open source multi-tool for exploring and publishing data
Stars: ✭ 5,640 (+13016.28%)
Mutual labels:  json, csv
Ason
[DEPRECATED]: Prefer Moshi, Jackson, Gson, or LoganSquare
Stars: ✭ 777 (+1706.98%)
Mutual labels:  json, convert
Json2csv
command line tool to convert json to csv
Stars: ✭ 742 (+1625.58%)
Mutual labels:  json, csv
Trdsql
CLI tool that can execute SQL queries on CSV, LTSV, JSON and TBLN. Can output to various formats.
Stars: ✭ 593 (+1279.07%)
Mutual labels:  json, csv
Jc
CLI tool and python library that converts the output of popular command-line tools and file-types to JSON or Dictionaries. This allows piping of output to tools like jq and simplifying automation scripts.
Stars: ✭ 967 (+2148.84%)
Mutual labels:  json, convert
Api
Our Database
Stars: ✭ 568 (+1220.93%)
Mutual labels:  json, csv
Countries
World countries in JSON, CSV, XML and Yaml. Any help is welcome!
Stars: ✭ 5,379 (+12409.3%)
Mutual labels:  json, csv
Servicestack
Thoughtfully architected, obscenely fast, thoroughly enjoyable web services for all
Stars: ✭ 4,976 (+11472.09%)
Mutual labels:  json, csv
Countries
Countries, Languages & Continents data (capital and currency, native name, calling codes).
Stars: ✭ 656 (+1425.58%)
Mutual labels:  json, csv
Pytablewriter
pytablewriter is a Python library to write a table in various formats: CSV / Elasticsearch / HTML / JavaScript / JSON / LaTeX / LDJSON / LTSV / Markdown / MediaWiki / NumPy / Excel / Pandas / Python / reStructuredText / SQLite / TOML / TSV.
Stars: ✭ 422 (+881.4%)
Mutual labels:  json, csv
Canmatrix
Converting Can (Controller Area Network) Database Formats .arxml .dbc .dbf .kcd ...
Stars: ✭ 486 (+1030.23%)
Mutual labels:  json, convert
Nano Sql
Universal database layer for the client, server & mobile devices. It's like Lego for databases.
Stars: ✭ 717 (+1567.44%)
Mutual labels:  json, csv
Ps Webapi
(Migrated from CodePlex) Let PowerShell Script serve or command-line process as WebAPI. PSWebApi is a simple library for building ASP.NET Web APIs (RESTful Services) by PowerShell Scripts or batch/executable files out of the box.
Stars: ✭ 24 (-44.19%)
Mutual labels:  json, csv

jsoncsv : easily convert json to csv or xls[x]

.. image:: https://img.shields.io/pypi/v/jsoncsv.svg :target: https://pypi.python.org/pypi/jsoncsv

.. image:: https://api.travis-ci.org/alingse/jsoncsv.svg?branch=master

.. image:: https://coveralls.io/repos/github/alingse/jsoncsv/badge.svg :target: https://coveralls.io/github/alingse/jsoncsv

jsoncsv (with mkexcel) is a command tool to convert json file to csv/xlsx file.

It's simple, and no need user to specify the keys.

Just use them.

Quick Start :

cat the raw.json to csv/xls use command line tool

.. code-block:: bash

cat raw.json | jsoncsv | mkexcel > output.csv
cat raw.json | jsoncsv | mkexcel -t xls > output.xls

make sure each line of raw json text file is a json object

.. code-block:: bash

$cat raw.json
{"id":1, "name":"A", "year": 2015}
{"id":2, "name":"S", "zone": "china"}
$cat raw.json | jsoncsv | mkexcel > output.csv
$cat output.csv
id,name,year,zone
1,A,2015,
2,S,,china

This is easily and needn't care the different keys from any two object.

if input file is an json_array, use -A/--array to decode it

.. code-block:: bash

$cat raw.json
[{"id":1, "name":"A", "year": 2015}, {"id":2, "name":"S", "zone": "china"}]
$cat raw.json | jsoncsv -A | mkexcel > output.csv
$cat output.csv
id,name,year,zone
1,A,2015,
2,S,,china

another way to convert file step by step

.. code-block:: bash

$jsoncsv raw.json expand.json
$mkexcel expand.json -t xls output.xls

get more options with --help.

.. code-block:: bash

jsoncsv --help
mkexcel --help

Install

.. code-block:: bash

pip install jsoncsv

Usage

see #QuickStart and get more options with --help.

just expand/restore the json, the expand json is one layer json.

.. code-block:: bash

jsoncsv raw.json expand.json
jsoncsv -r expand.json raw.json
cat raw.json | jsoncsv | jsoncsv -r > raw2.json

mkexcel the expanded json (one layer)

.. code-block:: bash

mkexcel expand.json output.csv
mkexcel -t xls expand.json > output.xls
mkexcel -t csv expand.json > output.csv

-e, --expand

expand json, 展开 json

.. code-block:: bash

$jsoncsv -e raw.json expand.json
$cat raw.json expand.json
{"s":[1,2,{"w":1}]}
{"s.2.w": 1,"s.0": 1,"s.1": 2}

{"s":[1,2,{"w":1}]} will transformed to {"s.2.w": 1,"s.0": 1,"s.1": 2}

the output "expand.json" is only one layer json, it can be easy change to csv or xlsx (with mkexcel)

-r, --restore

restore the expanded json ι‡ζž„θ’«ε±•εΌ€ηš„json

.. code-block:: bash

jsoncsv -r expand.json raw.json
cat expand.json raw.json
{"s.2.w": 1,"s.0": 1,"s.1": 2}
{"s": [1, 2, {"w": 1}]}

{"s.2.w": 1,"s.0": 1,"s.1": 2} change to {"s":[1,2,{"w":1}]}

-s, --separator

separator used for combine the keys in the tree

default separator is .

--safe

on safe mode, use escape separator to avoid confilct

expand:

['aa', 'bb', 'www.xxx.com'] --> 'aa\.bb\.www.xxx.com'

restore:

'aa\.bb\.www.xxx.com' --> ['aa', 'bb', 'www.xxx.com']

mkexcel

dump expanded (by jsoncsv) json file to csv or xls file

.. code-block:: bash

mkexcel expand.json output.csv

-t, --type

chose dump type in ['csv', 'xls'] default is 'csv'

.. code-block:: bash

cat expand.json|mkexcel -t csv > output.csv
cat expand.json|mkexcel -t xls > output.xls

NOTE/TODO

  1. dict keys can't be just array indexes

example:

.. code-block:: bash

echo '{"0":1,"1":[1,2]}'|jsoncsv -e| jsoncsv -r
[1, [1, 2]]
  1. mkexcel enable hooks

wait next next version

  1. unicodecsv is not good enough

but better than python strand library csv.

  1. Windows is poor support

see https://github.com/alingse/jsoncsv/issues/37

try use https://jsoncsv.jsonutil.online/ instead

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].