I am reading a csv-file with JDBC, using CsvJdbc. Some strings in the csv-file contains a “-char, how can I handle these situations?
When I am reading the csv-file with:
while (results.next()) {
String name = results.getString("Name");
...
}
I get this SQLException, on the line where I have while (results.next()) {
java.sql.SQLException: Unexpected '"' in position 19. Line=Mats "Matte" Tyr;12;;
How can I escape the “-chars so I can read the String? Or can a Java String not contain an “-char? Any other suggestions on how I can solve this problem?
This is nothing to do with Java, but the rules of CSV. A double quote needs to be escaped by doubling it to
""and enclosing the whole field value in double quotes.foo,bar,"a ""quoted"" string",bang