I also face the same problem with open csv and for fix the issue I use escaped character.
for ex:
CSVReader csvReader = new CSVReader(new FileReader(fileName), seprator,escaped_character);
In here open csv default use double quotes as escape_character(according to my knowledge)
In my case I use separator as pipe sign (|)
A2|G A A|Thilina|9022V|1|2|3|4|"Rubasingha"|'Abc|MATARA"|'No'|2012|1668.88
In here "Rubasingha" open and close the double quotes and in 'No' also open and close the single quotes. these two work perfectly in default open csv
but when we use 'Abc - only open single quotes - this also work fine
but MATARA" OR "MATARA - in here we have one double quote - in my case this generate error while reading the CSV using open csv
for fix the issue I reference this page (http://cs.swan.ac.uk/~csbob/teaching/java/JavaDemoNetbeans/opencsv-2.3/doc/)
There are constructors that cater for supplying your own separator and quote characters. Say you're using a tab for your separator, you can do something like this:
CSVReader reader = new CSVReader(new FileReader("yourfile.csv"), '\t');
And if you single quoted your escaped characters rather than double quote them, you can use the three arg constructor:
CSVReader reader = new CSVReader(new FileReader("yourfile.csv"), '\t', '\'');
You may also skip the first few lines of the file if you know that the content doesn't start till later in the file. So, for example, you can skip the first two lines by doing:
CSVReader reader = new CSVReader(new FileReader("yourfile.csv"), '\t', '\'', 2);
so I change the my default escape character to (^) sign without using double quotes as escape character.
CSVReader csvReader = new CSVReader(new FileReader(fileName), '|','^');
This is the way I fix the problem. Thanks