0

I am not an advanced Java developer.

I am working on a project to insert records into tables in a SQL database by reading the data in a CSV file. The Employee CSV file has several columns containing data. There is an XML file which contains the mapping information, that is, the XML file says which column in the CSV file contains what information.

I have been successful in reading the CSV file with the mapping in the XML file. I have also been successful in inserting the data in the CSV file into database tables. But there is a catch. The CSV file is a file containing the all the historical records of employees in chronological order (oldest record first). In the scenario where there are multiple records for an employee, his/her last record in the file contains his/her current information and needs to be inserted into the Employee table. All of his/her older records need to be inserted into the Employee_History table in the same order they appear in the CSV file. Column 0 of the CSV file contains the Employee ID. The following is to give an idea of what the CSV file looks like

Emp_ID|First Name|Last Name|Email|Update Date
123|John|Smith|john.smith01@email.com|01/01/2020
234|Bruce|Waye|bruce.wayne@wayneenterprises.com|02/02/2020
123|John|Smith|john.smith02@email.com|02/15/2020
345|Clark|Kent|clark.kent@dailyplanet.com|02/16/2020
123|John|Smith|john.smith03@email.com|02/20/2020  -- **Last record in the CSV file for Emp ID = 123**

Can anyone please tell me the best way to approach this? I am struggling to come up with a way to identify a given custodian's last record in the CSV file.

Guhan Murugesan
  • 89
  • 1
  • 1
  • 8

0 Answers0