Skip to content
Advertisement

In Java, how do you deal with double quote inside of a CSV that you need to parse

here is what I want to do,

This my spend.csv file :

JavaScript

From a table view :

Table View of the csv

And here is what I want as my output file named spend.xml :

JavaScript

In order to do that, I found some stuff here and there and managed to get this :

JavaScript

At this point the programm should print in the terminal the XML file but;

Sadly, because of the double quotes of each value in my CSV file, I’m having this issue :

java org.w3c.dom.domexception invalid_character_err an invalid or illegal xml character is specified

I think I’m missing something around those lines :

JavaScript

I would like to keep the double quotes in my CSV, if anyone as an idea feel free to tell me please!

Advertisement

Answer

Before you run your conversion, do a

JavaScript

Then run the conversion and when it is complete, reverse it and replace all the “####” in the string with double quotes

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement