CSV To JSON

With Python Pandas it is pretty simple to transform a CSV to JSON.

#!/usr/bin/env python3

import json
import csv
import sys

def main():
    csvInput = sys.stdin.readlines()

    data = []
    reader = csv.DictReader(csvInput)
    for row in reader:
        data.append(row)

    print(json.dumps(data, indent=4))

if __name__ == "__main__":
    main()

Reach out to me for professional support!

Contact