[英]how can I create a new .dbf file with python (solution with ethanfurman/dbf package will be preferred)
我在ethanfurman/dbf中找不到任何用于将数据写入给定文件路径而不是修改现有文件的公共方法。 我想从元组列表和“field_specs”字符串创建一个 dbf 文件。
在此解决方案中,作者提到了 dbf.Table.export() 但我无法从当前版本的 lib 中找到它。
创建表:
import dbf
new_table = dbf.Table('new_file_name.dbf', 'field1 C(10), field2 N(5,2)')
并将记录写入其中(或任何以读/写模式打开的表):
new_table.open(dbf.READ_WRITE)
# using tuples
new_table.append(('a value', 27.31))
# using a dictionary
new_table.append({'field1':'a value', 'field2': 27.31})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.