Dal*_*ley 5 python foxpro dbf dbase
我在这里使用一种古老的数据库格式,dbf 文件。不要问为什么,只知道某个软件决定扩展foxpro支持,因为微软决定扩展foxpro支持。现在,我在特定文件上收到以下错误。我已成功加载另一个文件,我很好奇该数据库是否有问题。我确信您可能需要查看数据库来确定这一点,但它的发布方式太大了,所以我会采取我能得到的。
Traceback (most recent call last):
File "billsapi.py", line 250, in <module>
x.getUsedGuns()
File "billsapi.py", line 72, in getUsedGuns
itemdb = dbf.Dbf('item.dbf', readOnly=True, ignoreErrors=True)
File "C:\Python27\lib\site-packages\dbfpy\dbf.py", line 135, in __init__
self.header = self.HeaderClass.fromStream(self.stream)
File "C:\Python27\lib\site-packages\dbfpy\header.py", line 127, in fromStream
_fld = fields.lookupFor(_data[11]).fromString(_data, _pos)
File "C:\Python27\lib\site-packages\dbfpy\fields.py", line 455, in lookupFor
return _fieldsRegistry[typeCode]
KeyError: '0'
Run Code Online (Sandbox Code Playgroud)
这是返回此错误的简单代码:
def getUsedGuns(self):
itemdb = dbf.Dbf('item.dbf', readOnly=True, ignoreErrors=True)
Run Code Online (Sandbox Code Playgroud)
就像我说的,我可以毫无问题地加载其他文件,但也许有解决这个特定错误的方法?
编辑:我还想指出该文件可以在 DBF View Plus 中打开、查看和修改。
您的回溯是 dbfpy 告诉您文件具有 dbfpy 不支持的字段类型代码 的方式0。这是 Visual FoxPro (“VFP”) 的东西。
这与备忘录文件无关。是的,如果有备注字段,它们会存储在.FPT文件中。foo.fpt访问时需要在场foo.dbf。
你说“”“我实际上最终使用了 python dBase 模块”“”...大概你指的是 Ethan Furman 的dbf模块,根据其PyPI 条目,该模块不支持 null 字段。
我有一个 DBF 阅读模块 ( pydbfrw),我一直打算“有一天”发布它。这是其文档的摘录:
Field Type Description DBF variety Python 2.x type
0 (digit zero) _NullFlags VFP N/A
Notes: This field type is used only for the hidden _NullFlags field which
is a bit mask saying which fields in the record should be interpreted as NULL.
Run Code Online (Sandbox Code Playgroud)
我的模块实现了识别这一点并None在需要时返回字段值。如果您想要该模块的副本,请找到我的电子邮件地址 - 例如 google(“john machin xlrd”) - 给我发送电子邮件,我会将其发送给您。
| 归档时间: |
|
| 查看次数: |
4232 次 |
| 最近记录: |