I am trying to parse a CSV file using OpenCSV. One of the columns stores the data in YAML serialized format and is quoted because it can have comma inside it. It also has quotes inside it, so it is escaped by putting two quotes. I am able to parse this file easily in Ruby, but with OpenCSV I am not able to parse it fully. It is a UTF-8 encoded file.
Here is my Java snippet which is trying to read the file
CSVReader reader = new CSVReader(new InputStreamReader(new FileInputStream(csvFilePath), "UTF-8"), ',', '\"', '\\');
Here are 2 lines from this file. First line is not being parsed properly and is getting split at ""[Fair Trade Certified]""
because of escaped double quotes I guess.
1061658767,update,1196916,Product,28613099,Product::Source,"---
product_attributes:
-
- :name: Ornaments
:brand_id: 49120
:size: each
:alcoholic: false
:details: ""[Fair Trade Certified]""
:gluten_free: false
:kosher: false
:low_fat: false
:organic: false
:sugar_free: false
:fat_free: false
:vegan: false
:vegetarian: false
",,2015-11-01 00:06:19.796944,,,,,,
1061658768,create,,,28613100,Product::Source,"---
product_id:
retailer_id:
store_id:
source_id: 333790
locale: en_us
source_type: Product::PrehistoricProductDatum
priority: 1
is_definition:
product_attributes:
",,2015-11-01 00:06:19.927948,,,,,,