Skip to content

harris-chiu/csv2json

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSV to Json converter

Requires Python 3.4+

Install

pip install csv2json

Usage

From a command line

csv-to-json [-h] [--compact] [--csv_delimiter CSV_DELIMITER] 
            [--csv_quotechar CSV_QUOTECHAR] [--sort_keys]
            [--custom_headers CUSTOM_HEADERS [CUSTOM_HEADERS ...]] 
            [--remove_empty]
            csv_input json_output

A command line example

$ cat file.csv
a,b
1,"foo""bar"
2,baz
$ csv-to-json < file.csv
[
    {
        "a": "1",
        "b": "foo\"bar"
    },
    {
        "a": "2",
        "b": "baz"
    }
]

As a library

from csv2json import convert, load_csv, save_json

with open('input.csv') as r, open('output.json', 'w') as w:
    convert(r, w)

About

Python3 csv to json convertor

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%