Good morning everyone, I have the following file:
10,44,22
10,47,12
15,38,3
15,41,30
16,44,15
16,47,18
22,38,21
22,41,42
34,44,40
34,47,36
40,38,39
40,41,42
45,38,27
45,41,30
46,44,45
46,47,48
About this file I want to make different queries, for example bring me the values that have the rows (x, 44, y) then the program brings me 10,44,22; 16.44.15; 34.44.40; 46,44,45, once the rows have been obtained, separate the variables x, and then bring me 10,22, 16,15, 34,40, 46,45. For this I made a program that reads the entire file and as it finds the numbers I put a conditional to store the value x, and a vector:
val in = newScanner("patSPO.csv")
val con:convst = new convst()
var yi:Int = 0
val nodey:Value = Val(y).value
yi=con.convN2I(nodey.name)
while (scannerHasNext(in)) {
val s = in.nextt(',')
val p = in.nextt(',')
val o = in.nextt('\n')
if (p == yi) {
val fields:Fields = Vector(s,o)
}
}
My problem at the moment is that I have to read the whole file every time I want to make a query, and this for very large files takes a lot of time, My question is if there is any way to upload this file to memory, for example a Map (ListMap, Collection, TreeMap) which allows me to make queries in a faster way, and does not have to consult the file every time need?