2013-05-22 19 views
0

我有一个使用.dbf和.fpt文件的遗留应用程序。我正在阅读和写这些文件,我想出了一种写这些文件但不使用fpt备忘录的方法。我正在使用python 2.7.2和dbf模块0.95.02。当我尝试使用dbf module时,在尝试使用FpTable时出现错误。使用Python写入带有fpt备忘录的dbf表

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

我期待创建一个读写带有fpt备忘录的dbf文件。创建索引文件.cdx的能力将是理想的。我愿意以任何方式做上述任何事情。

回答

0

简短的回答是不要直接使用FpTable。你应该可以,但我从来没有尝试过,因为我总是使用Table(name, fields, dbf_type='fp')

感谢您的回合错误报告。 ;)