I'm using Java CSVReader and CSVWriter from OpenCSV
public static void main(String[] args) throws IOException { File inputFile=new File("e:\\temp\\5.csv"); File outputFile=new File("e:\\temp\\5_out.csv"); CSVReader reader=new CSVReader(new FileReader(inputFile)); CSVWriter outputWriter = new CSVWriter(new FileWriter(outputFile),',', '"'); //CSVWriter outputWriter = new CSVWriter(new FileWriter(outputFile),',', '"','\\'); Listlines=reader.readAll(); outputWriter.writeAll(lines); outputWriter.flush(); outputWriter.close(); reader.close(); }
input1
"\"7 BURY NEW ROAD MANCHESTER","","","","Prestwich"
output1
"""7 BURY NEW ROAD MANCHESTER","","","","Prestwich"
I don't understand why the output is like that. Can someone explain the logic?
If I uncomment the lines where it's commented, basically tells the writer to use '\' to escape quotes and escape characters, it has the following results:
output2
"\"7 BURY NEW ROAD MANCHESTER","","","","Prestwich"
I also don't understand why the output is like that.