can anyone tell me how to import a .dbf file in python . I am a beginner.
I have a .dbf file with me at local location. I need to do some operations on the record, using Python.
can anyone tell me how to import a .dbf file in python . I am a beginner.
I have a .dbf file with me at local location. I need to do some operations on the record, using Python.
There is Python module called dbf which should allow you to read the data. The module supports dBase, FoxPro and Visual FoxPro files.
dbf 0.96.003 (https://pypi.python.org/pypi/dbf?)
Pure python package for reading/writing dBase, FoxPro, and Visual FoxPro .dbf files (including memos)
Package Documentation Currently supports dBase III, FoxPro, and Visual FoxPro tables. Text is returned as unicode, and codepage settings in tables are honored. Memos and Null fields are supported. Documentation needs work, but author is very responsive to e-mails.
Not supported: index files (but can create tempory non-file indexes), auto-incrementing fields, and Varchar fields.
Installation: pip install dbf
The best way to do this depends upon your needs. See this SO thread: What's the easiest way to read a FoxPro DBF file from Python?
I personally needed to import dbf files that were exported from GoldMine. I tried dbfpy and dbf by Ethan Furman. They both seemed like good packages, but neither could read "memo type" fields which were stored in adjacent DBT files (which is dBase IV format, and the way GoldMine exports certain fields). I found a package that does provide this functionality, however, which is dbfread. The trouble with that is it only reads. Those first packages also write to dbf. So, try those and see if they work for you. You may need a combination to take advantage of the strengths of the various options.
Good answers for this question have already been provided in the GIS stackexchange site - based on the same question asked for Python 3 since 2013