'How to avoid quoted commas parsing a CSV in JRuby

I'm trying to use the following line to parse a CSV into a table in JRuby.

   # Parse the CSV file into a table
   table = CSV.parse(File.read(tempFileName), headers: true)

The CSV file I'm using as input could have text columns that include commas. For these cases, I've included double quotation marks on the columns, to indicate that the internal commas on these columns should not be considered as delimiters.

For example, I could have the following CSV:

Address No, Alpha Name
1, Marcelo
2, "Surname, Name"

However, when I execute the code, I obtain the following error:

"Exception": "Message": "org.jruby.embed.InvokeFailedException: (MalformedCSVError) Illegal quoting in line 2.: tat RUBY.main

Is there any way to avoid this error indicating the correct quoting character and, also, is it going to avoid considering the internal quotes as column separators?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source