使用我的dbf模块基本流程如下:
import dbf
some_table = dbf.Table('/path/to/table.dbf') # table is closed
some_table.open()
index = some_table.create_index(record_indexer)
.
.
.
records = index.search(match=(some_value,)) # returns a dbf.List of matching records
Run Code Online (Sandbox Code Playgroud)
并且record_indexer是一个返回适当索引值的函数; 它可以很简单
lambda rec: rec.desired_field
Run Code Online (Sandbox Code Playgroud)
或者根据需要复杂:
def record_indexer(record):
if record.that_field == 'bad value':
return dbf.DoNotIndex # record is ignored
return record.this_field, record.other
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9431 次 |
| 最近记录: |