Search code examples
pythondbf

python dbf table.export | AttributeError: 'Db3Table' object has no attribute 'export'


I am working to use the dbf module for eventually editing a dbf file as part of a shapefile package. The dbf module out of the box seems far easier to use than the dbfpy module.

In any case, now I reach this point where I cannot export to a csv as the documentation says you can. I am a novice python person so perhaps I am syntactically challenged.

import dbf
table = dbf.Table("C:\dev\SHAPES/the-database.dbf")
table.open()

table.export(filename="C:\dev\SHAPES/the-csv.csv", header=False)

This is a pre-existing database with names and coordinate extents. What I am actually trying to do is programmatically rename about 5000 polygons within this shapefile.


Solution

  • Thank you to progmatico, by looking into the test.py I found the feature for importing a csv, which demonstrated to me how to export to csv. Here is my working script:

    import dbf
    table = dbf.Table("C:\dev\SHAPES/the-database.dbf")
    table.open(mode=dbf.READ_WRITE)
    
    dbf.export(table, table.filename, header=False)