使用Python用FPT备忘录编写dbf表 [英] Using Python to write dbf table with fpt memos

查看:147
本文介绍了使用Python用FPT备忘录编写dbf表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我想创建一个读写带有fpt备忘录的dbf文件的文件。创建索引文件.cdx的能力将是理想的选择。我愿意采取任何上述方法。

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.

推荐答案

简短的答案是不要直接使用 FpTable 。您应该可以,但是我从未真正尝试过,因为我总是使用 Table(name,fields,dbf_type ='fp')

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

这篇关于使用Python用FPT备忘录编写dbf表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆