Using Python to write dbf table with fpt memos

久未见 提交于 2019-12-14 03:12:24

问题


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:


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



来源:https://stackoverflow.com/questions/16682470/using-python-to-write-dbf-table-with-fpt-memos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!