dbfread icon indicating copy to clipboard operation
dbfread copied to clipboard

Only supports reading a file from the filesystem

Open maackle opened this issue 7 years ago • 5 comments

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.

maackle avatar Oct 09 '17 19:10 maackle

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?

rysson avatar May 30 '18 11:05 rysson

Looks like this project may be abandoned? Would be great to get this in

razor-1 avatar Nov 13 '19 21:11 razor-1

... and third. @rysson not sure if you can get a pull request accepted, but it's exactly what I need.

ptvirgo avatar Apr 20 '20 21:04 ptvirgo

... 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.)

olemb avatar Dec 21 '20 03:12 olemb

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

zaneselvans avatar Dec 21 '20 15:12 zaneselvans