简体   繁体   中英

dbf export cols to csv

Is it possible to export certain columns from a dbf database. The dbf table that I am trying to export has 150+ columns and I am only interested in 5. I am using the dbf module.

db = dbf.Table(dbf_link)
db.open()

dbf.export(db, filename='', fields='', format='csv', header=True)

gives me the error "unexpected keyword 'fields'"

When in doubt, check out the code ( latest available here ).

There is an export method that looks like this:

def export(
        table_or_records,
        filename=None,
        field_names=None,
        format='csv',
        header=True,
        dialect='dbf',
        encoding=None,
        ):

So you will want something like:

dbf.export(db, field_names=['field_1', 'field_2', ..., 'field_n'])

where field_1 , etc., are the actual field names you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM