Using Python to write dbf table with fpt memos

2019-08-22 03:31发布

I have a legacy application that uses .dbf and .fpt files. I am looking to read and write those files, I have figured out a way to write these files but not using fpt memos. I am using python 2.7.2 and dbf module 0.95.02. When I try to use the dbf module I get an error when trying to use FpTable.

>>> import dbf
>>> table = dbf.FpTable('test','name C(25); age N(3,0); qualified M')
>>> table
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/doctor/.virtualenvs/dbf/lib/python2.7/site-packages/dbf.py", line 4428, in __repr__
    return __name__ + ".Table(%r, status=%r)" % (self._meta.filename, self._meta.status)
  File "/Users/doctor/.virtualenvs/dbf/lib/python2.7/site-packages/dbf.py", line 4213, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Db3Table' object has no attribute '_meta'
>>> table.open()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/doctor/.virtualenvs/dbf/lib/python2.7/site-packages/dbf.py", line 4953, in open
    meta = self._meta
  File "/Users/doctor/.virtualenvs/dbf/lib/python2.7/site-packages/dbf.py", line 4213, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Db3Table

I am looking to create a to read and write dbf files with fpt memos. The ability to create index files .cdx would be a ideal. I am open to any way to do any of the above.

1条回答
在下西门庆
2楼-- · 2019-08-22 03:56

Short answer is don't use FpTable directly. You should be able to, but I've never actually tried since I always use Table(name, fields, dbf_type='fp').

Thanks for the round-a-bout bug report. ;)

查看更多
登录 后发表回答