I have a CSV file with student records. I would like to upload these records to a aluno
table in SQLite.
How can I perform this operation?
I have a CSV file with student records. I would like to upload these records to a aluno
table in SQLite.
How can I perform this operation?
You have to pass the data to object first. Then you enter the data in the bank. There is a framework for working with SQLite .
To pass the data from .CSV to object you will have to read row by line of CSV and break each line by the data divider (eg ; ). It takes each die and inserts it into its object.
Exemplo.
CSV
jose ; turma 301 ; 10 anos
joao ; turma 401 ; 11 anos
Stirng csv = leituraDeArquivoCSV();
List<Aluno> alunos = new ArrayList<Aluno>();
while(data.hasNext()){
Aluno aluno = new Aluno();
String[] data = csv.split(";");
aluno.setNome(data[0]);
aluno.setTurma(data[1]);
aluno.setIdade(data[2]);
alunos.add(aluno);
}
Now you can get the student object and save it normally.