0
I did the following instruction to upload a csv to the database:
public void importarBaseBruta(File arquivo) {
try {
this.limparBaseBruta();
this.con.conectar();
this.stm = this.con.getStm();
System.out.println("- IMPORTANDO BASE BRUTA");
String path = arquivo.getPath().replace("\\", "/");
String query = "LOAD DATA LOCAL INFILE '" + path + "' INTO TABLE base_bruta \n"
+ "CHARACTER SET 'latin1' \n" + "FIELDS TERMINATED BY ';' ENCLOSED BY '\"' \n" + " IGNORE 2 LINES;";
this.stm.executeUpdate(query);
this.con.fechar();
System.out.println("- TERMINOU DE IMPORTAR A BASE BRUTA DIARIA");
} catch (Exception e) {
System.out.println("ERRO NO MOMENTO DE IMPORTAR: " + e.getMessage());
e.printStackTrace();
}
}
But when csv goes up to the bank the column moves because of quotation marks that are not removed:
Displaced column:
I would like to know how to remove it.
Reading each line of the file and doing a replace?
– Costamilam
I made this method for that but it continues the same thing https://pastebin.com/2dMDPWcu
– user71502