我使用this库在python中读取dbf文件。如何获得列的MAX值。我想要以下sql
SELECT MAX(DATE_OPEN) FROM MYFILE.DBF
答案 0 :(得分:3)
因为dbf库不支持完整的sql(事实上,我将现有的功能重命名为pql
以强调这一点),所以你必须编写自己的max
例程。这样的事情可以解决问题:
def field_max(table, field):
"""
return the maximum value for column `field` in table
table should be a collection of records or an open table
field should be a field name (either `str` or `unicode`)
"""
return max([rec[field] for rec in table])