1
I am implementing a CSV file upload, currently I am able to count how many lines has the CSV, I am able to identify when errors exist in the CSV as shown in the algorithm below;
File arquivoLeitura = new File(getArquivo());
LineNumberReader linhaLeitura = new LineNumberReader(new FileReader(arquivoLeitura));
linhaLeitura.skip(arquivoLeitura.length());
int qtdLinha = linhaLeitura.getLineNumber() + 1;
BufferedReader leitor = new BufferedReader(new InputStreamReader(new FileInputStream(getArquivo())));
String linha = null;
int indiciosComErros = 0;
for (int i = 1; i <= qtdLinha; i++ ) {
linha = leitor.readLine();
String[] dadosCSV = linha.split(VIRGULA);
System.out.println(Arrays.toString(dadosCSV));
System.out.println( dadosCSV[0]);
System.out.println( dadosCSV[1]);
System.out.println( dadosCSV[2]);
System.out.println( dadosCSV[3]);
System.out.println( dadosCSV[4]);
System.out.println(dadosCSV[5]);
System.out.println("--------------------------");
if (pessoaJuridicaPublicaService.getPorId(Long.parseLong(dadosCSV[1])) == null) {
indiciosComErros = indiciosComErros + 1;
}
}
leitor.close();
Now I need to know which lines are wrong, example;
If you have 50 records and you have an error on line 1 and another on line 20, they will be identified. If you have 50 records and you have an error on line 10 and another on line 15 and another on line 30 and another on line 50 they are identified.
I need help because I have no idea how to accomplish this implementation!
Thank you very much, thank you very much :)
– wladyband