I am facing the problem of reading in a certain number
which is not unique and a date
which is also not unique to this number.
The program is extremely computational intensive and performs not so well on my ide, therefore I am facing the problem of using the right data structure.
At the moment I have created an index
and I read the number
into one HashMap and the date
into the other HashMap
. Then I am just matching them if I need them. However the reading in takes two functions each with a while loop.
public HashMap<String,String> getEventDates() throws Exception {
String csvFile = "C:\\Users\\test.csv";
CSVReader reader = new CSVReader(new FileReader(csvFile), ';');
String [] line;
HashMap<String, String> eventMap = new HashMap<String, String>();
while ((line = reader.readNext()) != null) {
eventMap.put(line[15], line[13]);
}
reader.close();
return eventMap;
}
public HashMap<String,String> getNumberToEventDates() throws Exception {
String csvFile = "C:\\Users\\test.csv";
CSVReader reader = new CSVReader(new FileReader(csvFile), ';');
String [] line;
HashMap<String, String> isinMap = new HashMap<String, String>();
while ((line = reader.readNext()) != null) {
isinMap.put(line[15], line[4]);
}
reader.close();
return isinMap;
}
Which data structure should I use to perform better? How can I merge these two methods?
I appreciate your answers!
UPDATE
Oh I am so sorry.
In fact after every while iteration line[15]
which is just an index created by me.
How can I merge this two functions?