dbfread
dbfread copied to clipboard
feature request: support non-seekable input files
First of all, what a wonderfully-coded and -documented project!
Second: It would be awesome if non-seekable files (FIFOs for example) were able to be used as input files; this way dbfread can be used for unix-style command-line filters.
It seems like there are not too many seek statements, so hopefully this is not too difficult; if it isn't very easy/quick, I may be able to give it a try.
Thank you! :)
Reading from streams could be useful, but there are a few hurdles:
- The DBF class opens and closes the file when reading the header and opens and closes it again when you iterate over records or do len(). It would have to be rewritten to work like today if you pass a filename and to keep the file open if you pass an already open file-like object.
- You could read normal records or deleted records but not both. (Only the first iteration or call to len() would do anything.) This would be inconsistent with the current behaviour.
- Memo files wouldn't work.
- I've already removed one seek and the one that skips to the start of the first record could be a read instead. However reading instead of skipping records could hurt performance for seekable files. (Especially in len().)
Perhaps it's best to rearrange the code and add a StreamingDBF class. This would make the code cleaner and the API less confusing.
I don't have much time to work on dbfread at the moment but feel free to have a go at it. If you do make sure you fork the develop branch.