Skip to content

cvs: Add more from/to options - #546

Open
wader wants to merge 1 commit into
masterfrom
csv-options
Open

cvs: Add more from/to options#546
wader wants to merge 1 commit into
masterfrom
csv-options

Conversation

@wader

@wader wader commented Jan 3, 2023

Copy link
Copy Markdown
Owner

Add header option, on by default
Disable comments by default
Rename comma to delimiter
Add quote_char option
Add skip initial space option

Uses a forked version of std csv to support custom quote character

See top of csv.go for TODOs

@wader

wader commented Jan 3, 2023

Copy link
Copy Markdown
Owner Author

Related to #528

@wader

wader commented Jan 3, 2023

Copy link
Copy Markdown
Owner Author

See TODOs in csv.go, there are some questions how to handle header ordering, comments error conditions etc

With this one can do:

$ go run . -rn '[{a:"aaa",b:"hello"}, {a: "aaa", b: "world"}] | . as $v | to_csv | ., (from_csv | ., . == $v)'
a,b
aaa,hello
aaa,world

[
  {
    "a": "aaa",
    "b": "hello"
  },
  {
    "a": "aaa",
    "b": "world"
  }
]
true
$ go run . -rn '[["aaa","hello"], ["aaa","world"]] | . as $v | to_csv | ., (from_csv({header: false}) | ., . == $v)'
aaa,hello
aaa,world

[
  [
    "aaa",
    "hello"
  ],
  [
    "aaa",
    "world"
  ]
]
true

Add header option, on by default
Disable comments by default
Rename comma to delimiter
Add quote_char option
Add skip initial space option

Uses a forked version of std csv to support custom quote character

See top of csv.go for TODOs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant