dbfread
dbfread copied to clipboard
Only supports reading a file from the filesystem
It would be great if the API would take file-like objects as input, rather than a string to the file path. In my case, I load DBF file data directly from an API into a io.BytesIO
object and want to operate on that data directly. To use dbfread I'd have to save it to a temp file.
Hi,
It's necessary form me too. I've created simple patch: https://github.com/rysson/dbfread/commit/ae3162d6c363de169666182e94704f327687a5c7
File-like object is used directly if seek-able. If not, io.BytesIO is used.
Now you can:
with zipfile.ZipFile('/path/to/file.zip', 'r') as zf:
with zf.open('BAZA/ZESPOLY.DBF') as z:
for record in DBF(z):
print(record)
BTW. Next commit adds code page 'mazovia' support.
@olemb, could you give me a comment? Can i create pull-request?
Looks like this project may be abandoned? Would be great to get this in
... and third. @rysson not sure if you can get a pull request accepted, but it's exactly what I need.
... and fourth.
I am very sorry that I had to abandon the project for a long time time for reasons I won't go into here (in short, life happened), but I am starting up again now and this is at the top of the list of new features to add. It's very highly requested and would be useful in a lot of different situations.
Since there are now several issues pull requests I've made a meta-issue #53 where we can discuss the pros and cons of the different implementations.
I will have to read the code and discussions on each issue before I'm ready to give any informed answers.
(Edit: forgot to add the issue number.)
We created a fork over here that does some of this, if it's useful to you at all: https://github.com/catalyst-cooperative/dbfread