Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
NAME
csv2json - CSV to JSON format converter

SYNOPSIS
csv2json [OPTION...] [-s] FILE...
csv2json [OPTION...] [-o OUTPUT_FILE]

DESCRIPTION
Convert comma-separated value (CSV) FILEs into javascript object notation (JSON) files. The output file will have the same file name as FILE has with the file extension
replaced with .json. The output will be written to the standard output if -s option is specified.

If FILEs are not specified, csv2json reads its input from standard input and writes output to standard output; the output can be redirected to a file by -o option.

The first line in the input is expected to be a row containing a list of column names by default; this can be turned off by -N option. If column names are not included
in the input, a list of default column names are generated which follow 'columnN' naming convention where 'N' is an integer and starts from 1.

OPTIONS
If both short form and long form are specified on the command line, the long form will take precedence.

-c CHARSET
The character set to be used for encoding/decoding data; supported values are: 'UTF-8' and 'platform-default', default to 'UTF-8'.

-d DELIMITER
The delimiter for separating data; default to ','. Use word 'tab' for setting tab character as delimiter.

-l LINE_SEPARATOR
The line separator to be used in the output file; supported values are: 'unix', 'windows', default to platform's line separator.

-i
Prompt before overwriting the output file.

-N
Indicate the first line in the input is a row of data but not a row containing a list of column names.

-o OUTPUT_FILE
Redirect output to the file specified by OUTPUT_FILE if input is read from standard input.

-p
Preserve the last-modified time of the output file if it exists.

-s
Redirect output to the standard output if FILEs are specified.

-NT, --null-text BOOLEAN
Indicates if NULL value is represented as (null) text, default to 'false'. See BOOLEAN VALUES section below for supported BOOLEAN values.

-PA, --datetime PATTERN
Pattern for formatting date and time, default to 'yyyyMMdd HH:mm:ss.SSS'.

-PD, --date PATTERN
Pattern for formatting date, default to 'yyyyMMdd'.

-PT, --time PATTERN
Pattern for formatting time, default to 'HH:mm:ss.SSS'.

-SQ, --string-quote IDENTIFIER
String quoted identifier; supported values are: 'double-quote', 'single-quote', 'none', default to 'double-quote'.

BOOLEAN VALUES:
The followings are supported BOOLEAN values: 'true', 'false', 'yes', 'no', 'y', 'n', 'on', 'off', '1', '0'.

NOTES
On -o option, the .json file extension will not be added to OUTPUT_FILE if OUTPUT_FILE does not have a file extension.

SEE ALSO
csv2excel
csv2html
csv2xml