mardi 21 février 2017

How to randomly read a line from a big csv file in java

I have a big csv file whose size is not specific and maybe more than 4 GB. Now I need to read some lines from the file randomly as test cases to do some tests in an application. It's impossible to read all to the memory because of the size of memory(outofmemory exception).

One solution is to generate an array of some numbers falling in the range of the total number. Then sort the list. At last read from the file line by line according to the number stored in the array. So I could get a random set of lines from the csv file.

Is there a library or method to read a line from a big csv file randomly?




Aucun commentaire:

Enregistrer un commentaire