[Bug 1714760] Re: "csvtool" returns wrong output when escaping double quotes

2018-01-15 Thread Sven K.
After stumbling upon the same issue, I realized that this is not a bug,
but intended behavior.

The output of csvtool is always a valid csv-formatted record again. It
removes any obsolete double quotes, but it keeps all *necessary* double
quotes.

In your example, csvtool gives the following output

$csvtool col 1,2,3 test.csv
foo,"""Hello "" World!""",bar

which is indeed a correct csv-record. Moreover, the double quotes are
neccessary, since the unescaped output

foo,"Hello " World!",bar

would yield a corrupt csv-record.

The same holds even true for the output's separator char as defined by
the -u flag. Consider the following example:

$ echo "\"single,field\",next one" | csvtool col 1,2 -
"single,field",next one

Again the surrounding quotes are *not* removed because they are
mandatory because of the comma inside the field. However, when
specifying by -u ; another output separator, the double quotes become
obsolete and will be removed:

$ echo "\"single,field\",next one" | csvtool col 1,2 -u ";" -
single,field;next one

Summarized: csvtool focuses on generating valid csv output, *not* on
extracting individual field values in always their unescaped form.
Unfortunately, this means that one needs another commandline tool to
post-process the somtimes-escaped-sometimes-unescaped output of csvtool
when trying to use it in scripts to extract a single column.

It could be a feature request (and indeed a very helpful feature) to
support a flag that forces the output to be unescaped without any
surrounding double quotes, e.g., csvtool --unquoted col 2 test.csv could
give "Hello " World!" then, which is intended for further processing,
rather than """Hello "" World!""".

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1714760

Title:
  "csvtool" returns wrong output when escaping double quotes

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ocaml-csv/+bug/1714760/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1714760] Re: "csvtool" returns wrong output when escaping double quotes

2018-01-15 Thread Launchpad Bug Tracker
Status changed to 'Confirmed' because the bug affects multiple users.

** Changed in: ocaml-csv (Ubuntu)
   Status: New => Confirmed

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1714760

Title:
  "csvtool" returns wrong output when escaping double quotes

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ocaml-csv/+bug/1714760/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs