1.0.2 • Published 11 months ago

@duypn/csv-to-json v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

CSV to JSON Converter

This script converts CSV files to JSON format.

Usage

To use the CSV to JSON converter, run the script with the following command:

csv-to-json --csvDir=<path/to/csv/files> --objName=<name/of/the/object/key> [--jsonDir=<path/to/output/json/files>] [--columns=<comma/separated/list/of/columns>]

Example:

csv-to-json --csvDir=./test --objName=Key --columns=en,ja,fr

Arguments

ArgumentDescriptionDefaultRequired/Optional
--csvDirDirectory containing CSV files-Required
--objNameName of the object/key in CSV-Required
--jsonDirOutput directory for JSON filesSame as csvDirOptional
--columnsComma-separated list of columns to include-Optional

Functionality

  1. Reads CSV files from the specified directory
  2. Parses each CSV file, converting it to a JSON structure
  3. Optionally filters columns based on the --columns argument
  4. Saves each converted file as a JSON in the output directory

Output

The script generates JSON files with the following structure:

{
  "name": "<fileName>",
  "items": {
    "<key1>": {
      "<property1>": "<value1>",
      "<property2>": "<value2>",
      "<property3>": "<value3>"
    },
    "<key2>": {
      "<property1>": "<value1>",
      "<property2>": "<value2>",
      "<property3>": "<value3>"
    }
  }
}
1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago