I have a data for some statistical calculations,
item1, item2, sim
...
9,471,0.9889886
19,591,0.98890734
453,15,0.98842293
10,20,0.98759043
68,713,0.9847893
71,582,0.9836043
95,13,0.98339003
42,190,0.9832126
1,52,0.9828053
102,275,0.981985
110,1115,0.9810662
203,116,0.98054993
1098,14,0.98008114
13,56,0.9965508
7,22,0.9963229
69,96,0.9959787
896,79,0.9959084
...
nearly 20k rows.
In Java i want to populate an array like below from this data
array[col1][col2] = value
The problem is 'col1' and 'col2' values are not sequential, ordered and there are gaps between min-max values.
As i expected if I want to fill this data in a java array it is giving me 'IndexOutOfBoundsException' as i expected.
I tried some ArrayList, Matrix but they have been started indis from zero and it lose meaning of data. I want to compare this data with itself again in an iteration and want some calculations distance etc.
Which Java Collection API do you refer for this?
Edit: I pasted my code for the comments
public class CSVFileReader {
public static final double[][] readItemSimilarityFromFile(File f)
throws IOException {
try (final BufferedReader br = new BufferedReader(new FileReader(f))) {
// we have 20k line
final int[][] matrix = new int[20000][20000];
while ((String line = br.readLine()) != null) {
int values = line.split(",", -1);
matrix[values[0]][values[1]] = values[2];
}
}
br.close();
return matrix;
}
}