Thanks to visit codestin.com
Credit goes to github.com

Skip to content

csv2json issues #291

@datatraveller1

Description

@datatraveller1

Prerequisites

version: csvtk v0.30.0

Describe your issue

I have noticed four issues with the csv2json command.

command: csvtk csv2json testdata.csv -o testdata.json

input file testdata.csv:
test
none
"Make America ""great"" again"
\nations
"This is a
MULTILINE
string"

actual output file testdata.json:

[
  {
    "test": null
  },
  {
    "test": "Make America "great" again"
  },
  {
    "test": "\nations"
  },
  {
    "test": "This is a
MULTILINE
string"
  }
]

expected output file testdata.json:

[
  {
    "test": "none"
  },
  {
    "test": "Make America \"great\" again"
  },
  {
    "test": "\\nations"
  },
  {
    "test": "This is a\nMULTILINE\nstring"
  }
]

Comments:

  • issue 1: I want "none" to be depicted literally and neither changed to "null" (no option) nor "" (empty string with option -b)

  • issue 2: In JSON, double quotes have to be escaped with a backslash (\")

  • issue 3: In JSON, backslashes have to be escaped with a backslash (\\)

  • issue 4: In JSON, the line breaks of a CSV multiline cell have to be depicted as \n

Thank you

Thank you very much for the great csvtk tool!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions