Public bug reported:

Hello:

I'm using "csvtool" to get a column from a CSV file, with the subcommand
"col". This file has one column with escaped double quotes that makes
this command to return the wrong output. There are escaped quotes at the
beginning of the column, in the middle, and at the end. But "csvtool"
doesn't remove the double quotes that surround the column (the non-
escaped ones), nor un-escapes the escaped quotes (it should transform ""
to ").

Suppose that you have a file called "test.csv" with this single line:

  "foo","""Hello "" World!""","bar"

It has 3 columns, all them quoted. The one in the middle has 3 double
double-quotes (escaped quotes).

When I execute these commands, I expect the following output:

  $ csvtool col 1 test.csv
  for

  $ csvtool col 2 test.csv
  "Hello " World!"

  $ csvtool col 3 test.csv
  bar

But I get this output:

  $ csvtool col 1 test.csv
  for

  $ csvtool col 2 test.csv
  """Hello "" World!"""

  $ csvtool col 3 test.csv
  bar

"csvtool" seems to return the 2nd column as is, without any
transformation.

This is the information of my current install:

  * Distribution: Ubuntu 16.04.3 LTS
  * Architecture: amd64
  * Kernel: 4.4.0-92.115
  * libc6: 2.23-0ubuntu9
  * csvtool: 1.4.2-1

Thank you.

** Affects: ocaml-csv (Ubuntu)
     Importance: Undecided
         Status: New

** Summary changed:

- Wrong output when escaping double quotes
+ "csvtool" returns wrong output when escaping double quotes

** Description changed:

  Hello:
  
  I'm using "csvtool" to get a column from a CSV file, with the subcommand
  "col". This file has one column with escaped double quotes that makes
  this command to return the wrong output. There are escaped quotes at the
  beginning of the column, in the middle, and at the end. But "csvtool"
  doesn't remove the double quotes that surround the column (the non-
  escaped ones), nor un-escapes the escaped quotes (it should transform ""
  to ").
  
  Suppose that you have a file called "test.csv" with this single line:
  
-   "foo","""Hello "" World!""","bar"
+   "foo","""Hello "" World!""","bar"
  
  It has 3 columns, all them quoted. The one in the middle has 3 double
  double-quotes (escaped quotes).
  
  When I execute these commands, I expect the following output:
  
-   $ csvtool col 1 test.csv
-   for
+   $ csvtool col 1 test.csv
+   for
  
-   $ csvtool col 2 test.csv
-   "Hello " World!"
+   $ csvtool col 2 test.csv
+   "Hello " World!"
  
-   $ csvtool col 3 test.csv
-   bar
+   $ csvtool col 3 test.csv
+   bar
  
  But I get this output:
  
-   $ csvtool col 1 test.csv
-   for
+   $ csvtool col 1 test.csv
+   for
  
-   $ csvtool col 2 test.csv
-   """Hello "" World!"""
+   $ csvtool col 2 test.csv
+   """Hello "" World!"""
  
-   $ csvtool col 3 test.csv
-   bar
+   $ csvtool col 3 test.csv
+   bar
  
  "csvtool" seems to return the 2nd column as is, without any
  transformation.
  
  This is the information of my current Debian install:
  
-   * Distribution: Ubuntu 16.04.3 LTS
-       * Architecture: amd64
-   * Kernel: 4.4.0-92.115
-   * libc6: 2.23-0ubuntu9
-   * csvtool: 1.4.2-1
+   * Distribution: Ubuntu 16.04.3 LTS
+   * Architecture: amd64
+   * Kernel: 4.4.0-92.115
+   * libc6: 2.23-0ubuntu9
+   * csvtool: 1.4.2-1
  
  Thank you.

** Description changed:

  Hello:
  
  I'm using "csvtool" to get a column from a CSV file, with the subcommand
  "col". This file has one column with escaped double quotes that makes
  this command to return the wrong output. There are escaped quotes at the
  beginning of the column, in the middle, and at the end. But "csvtool"
  doesn't remove the double quotes that surround the column (the non-
  escaped ones), nor un-escapes the escaped quotes (it should transform ""
  to ").
  
  Suppose that you have a file called "test.csv" with this single line:
  
    "foo","""Hello "" World!""","bar"
  
  It has 3 columns, all them quoted. The one in the middle has 3 double
  double-quotes (escaped quotes).
  
  When I execute these commands, I expect the following output:
  
    $ csvtool col 1 test.csv
    for
  
    $ csvtool col 2 test.csv
    "Hello " World!"
  
    $ csvtool col 3 test.csv
    bar
  
  But I get this output:
  
    $ csvtool col 1 test.csv
    for
  
    $ csvtool col 2 test.csv
    """Hello "" World!"""
  
    $ csvtool col 3 test.csv
    bar
  
  "csvtool" seems to return the 2nd column as is, without any
  transformation.
  
- This is the information of my current Debian install:
+ This is the information of my current install:
  
    * Distribution: Ubuntu 16.04.3 LTS
-   * Architecture: amd64
+   * Architecture: amd64
    * Kernel: 4.4.0-92.115
    * libc6: 2.23-0ubuntu9
    * csvtool: 1.4.2-1
  
  Thank you.

-- 
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

Reply via email to