Clean

Use when you need to convert a CSV file to JSON format.

8ddieHu0314 5be1f8d 483 B Updated

File contents

CSV to JSON Converter

Read the input CSV file and convert it to a JSON array of objects.

import csv, json, sys

with open(sys.argv[1]) as f:
    rows = list(csv.DictReader(f))

print(json.dumps(rows, indent=2))

Pass the path to your CSV as the first argument. Each row becomes a JSON object with the header row as keys. Output goes to stdout so you can pipe or redirect it.

8ddieHu0314/Skill-Lab/tree/main/tests/fixtures/skills/security/clean commit 5be1f8d6a3

Frequently asked questions

npx skillmds@latest add 8ddiehu0314/clean