|laziness, impatience, and hubris|
Using indexing for faster lookup in large fileby anli_ (Novice)
|on Feb 27, 2015 at 17:55 UTC||Need Help??|
anli_ has asked for the
wisdom of the Perl Monks concerning the following question:
I'm trying to get a grip on indexing and how it works.
My current problem is that I would like to make a simple text lookup in a very large file.
The output I would like would be something like: Homininae,Homo,Homo sapiens
One way would be to use bash grep and do a search like:grep "^3005698;" database.txt
Then I could parse the output to make it pretty.
Using perl, they way I would normally do it would be to generate a hash of the database and then do my lookups from that, like so
The problem I have with this is that the database is around 30Gb, so it would be a very slow and memory consuming process. So my question is, can I somehow index the database, so I know where in the file the query '3005698' resides, to speed up this process.