Saya punya banyak file FoxPro (VFP9) DBF di sistem Ubuntu saya, apakah ada perpustakaan untuk membukanya di Python? Saya hanya perlu membacanya, dan lebih disukai memiliki akses ke bidang memo juga.
Update: Terima kasih @cnu, saya menggunakan Yusdi Santoso's dbf.py
dan bekerja dengan baik. Satu kendala: Ekstensi nama file memo harus menggunakan huruf kecil, yaitu .fpt
, bukan .FPT
yang merupakan nama file yang berasal dari Windows.
Saya lebih suka dbfpy. Ini mendukung pembacaan dan penulisan .DBF
file dan dapat mengatasi sebagian besar variasi format. Ini adalah satu-satunya implementasi yang saya temukan yang dapat membaca dan menulis file DBF lama dari beberapa sistem lama yang pernah saya kerjakan.
I was able to read a DBF file (with associated BAK, CDX, FBT, TBK files**) using the dbf package from PyPI http://pypi.python.org/pypi/dbf . I am new to python and know nothing about DBF files, but it worked easily to read a DBF file from my girlfriend's business (created with a music store POS application called AIMsi).
After installing the dbf package (I used aptitude and installed dbf version 0.88 I think), the following python code worked:
from dbf import *
test = Table("testfile.dbf")
for record in test:
print record
x = raw_input("") # to pause between showing records
That's all I know for now, but hopefully it's a useful start for someone else who finds this question!
April 21, 2012 SJK Edit: Per Ethan Furman's comment, I should point out that I actually don't know which of the data files were necessary, besides the DBF file. The first time I ran the script, with only the DBF available, it complained of a missing support file. So, I just copied over the BAK, CDX, FPT (not FBT as I said before edit), TBK files and then it worked.
Jika Anda masih memeriksa ini, saya memiliki konverter GPL FoxPro-to-PostgreSQL di https://github.com/kstrauser/pgdbf . Kami menggunakannya untuk secara rutin menyalin tabel-tabel kami ke dalam PostgreSQL untuk pelaporan cepat.
Anda dapat mencoba ini resep di Active State.
Ada juga modul DBFReader yang bisa Anda coba.
Untuk dukungan untuk memo field.
Check out http://groups.google.com/group/python-dbase
It currently supports dBase III and Visual Foxpro 6.0 db files... not sure if the file layout change in VFP 9 or not...
It's 2016 now and I had to fiddle with the dbf package to get it to work. Here is a python3 version to just export a dbf file to a csv
import dbf
d=dbf.Table('mydbf.dbf')
d.open()
dbf.export(d, filename='mydf_exported.csv', format='csv', header=True)
I had some unicode error at first, but got around that by turning off memos.
import dbf
d=dbf.Table('mydbf.dbf', ignore_memos=True)
d.open()
dbf.export(d, filename='mydf_exported.csv', format='csv', header=True)