Hi. I'm new to python so I apologize the answer to this is obvious to people who know the conventions.
I've got a large file of MARC records. What I'm working on right know is importing them into a database. This is mostly for experimentation purposes, not trying anything serious yet. So I set up a loop to iterate over all the records. But wouldn't you know it, some of the entries are "special", badly formatted or just missing information. Every so often I come across one of these gems, I either dump it or add contingencies to deal with any like it.
My issue is that, now that I'm a few 100,000 records into my file, it takes a while to get back to where I was reading through the file sequentially. That introduces a delay into the debug cycle which is a bit frustrating. Is there a way to just skip ahead a specific number of records?
At first I thought I could do something I've done with other iterators like:
for record in reader[400000:]:
but it says the reader object is not subscriptable.
Right now I'm using a second loop to get where I want to go like:
It's faster than my main loop but still takes a few minutes. It seems like if the reader could just jump over the length of a record that would go faster than creating a record object based on it, etc, but I can't figure out if there's a way to do that.