Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9004665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:56:48+00:00 2026-06-16T00:56:48+00:00

Python newbie here so please be gentle. I’m trying to convert dbf file to

  • 0

Python newbie here so please be gentle.

I’m trying to convert dbf file to csv. I stumbled upon a previous, similar question (with opposite conversion though) and was thinking abou using dbf module.

Using example from the docs I tried this code:

import dbf

dbf_fn = r'_PATH_HERE_\dbffile.dbf'
csv_fn = r'_PATH_HERE_\csvfile.csv'

in_db = dbf.Table(dbf_fn)

in_db.export(filename=csv_fn, header=True)

When I try to run it I get the following error:

Traceback (most recent call last):
  File "<pyshell#24>", line 1, in <module>
    in_db.export(filename=csv_fn, header=True)
  File "C:\Python27\ArcGIS10.1\lib\site-packages\dbf.py", line 3379, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Db3Table' object has no attribute 'export'

Why does the export fail?


Update:

As suggested by chm I now use:

dbf.export(in_db, csv_fn, header=True)

This still causes problem:

Traceback (most recent call last):
  File "D:\Data_RP\data\projects\kN\GIS\python\04_convert_dbf_ALT.py", line 31, in <module>
    dbf.export(in_db, filename=csv_fn, header=True)
  File "C:\Python27\ArcGIS10.1\lib\site-packages\dbf.py", line 5670, in export
    table = source_table(table_or_records[0])
  File "C:\Python27\ArcGIS10.1\lib\site-packages\dbf.py", line 3384, in __getitem__
    return self._table[value]
  File "C:\Python27\ArcGIS10.1\lib\site-packages\dbf.py", line 3175, in __getitem__
    raise DbfError("%s is closed; record %d is unavailable" % (meta.filename, index))
DbfError: D:\Data_RP\data\projects\kN\GIS\shapes\SWM_4N.dbf is closed; record 0 is unavailable
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:56:50+00:00Added an answer on June 16, 2026 at 12:56 am

    I find that the doc on the site is wrong.If you use help in your code,you can see the right doc as below:

    export(table_or_records, filename, field_names=None,
    format='csv', header=True, codepage=None)
    writes the records using CSV or tab-delimited format, using the filename
    given if specified, otherwise the table name
    if table_or_records is a collection of records (not an actual table) they
    should all be of the same format
    

    1.export now is not a member of class Table.
    Just use
    dbf.export(in_db, csv_fn, header=True)
    instead of
    in_db.export(filename=csv_fn, header=True)

    2.use open after create table (code sample:)

    import dbf
    
    csv_fn = r'sdv.csv'
    
    table = dbf.Table('temptable.dbf')
    table.open()
    
    dat=('John Doe', 31)
    table.append(dat)
    dbf.export(table, csv_fn, header = True)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Python newbie here. I was trying to troubleshoot an issue with writing a csv
I'm feeling dumb. Python & xpath newbie here. I'm trying to extract the complete
I am a python newbie here... I have a gzipped file (C:\sample.gz) that I
I'm trying to do the following with numpy (python newbie here) Create a zeroed
Python newbie here, running 2.7. I am trying to create a program that uses
Python newbie here. I'm trying to package a console app following this doc .
Python newbie here. I'm trying to create a black jack game in which the
Newbie here trying to use python to do some database analysis. I keep getting
I am newbie in Python and I need help: I have a file with
I'm a Python(3.1.2)/emacs(23.2) newbie teaching myself tkinter using the pythonware tutorial found here .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.