Skip to main content

Convert a CSV file into JSON format based on CSV headers

Project description

CONVCSV2JSON

Convert a CSV file into JSON format based on CSV headers

pip install convcsv2json

Usage

from convcsv2json import csv2json

data=csv2json(
    'sample.csv',        # CSV filename
    intend=4,            # JSON intendation
    numbered=True        # Set JSON data in numbered format or not
    )
print(data.conv()) # Print in JSON format
data.export('export.json') # Export the data into a JSON file

"intend" and "numbered" parameters are optional. By default, "intend" is set as None and "numbered" is set as False

from convcsv2json import csv2json
print(csv2json('sample.csv',4).conv())

Sample CSV

name,age
kewldog,12
kewlcat,23

Generated JSON

[
    {
        "name": "kewl",
        "age": "344"
    },
    {
        "name": "noice",
        "age": "456"
    }
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

convcsv2json-1.5.tar.gz (14.4 kB view hashes)

Uploaded Source

Built Distribution

convcsv2json-1.5-py3-none-any.whl (14.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page