Skip to content

Instantly share code, notes, and snippets.

@sheran
Created October 11, 2011 17:24
Show Gist options
  • Save sheran/1278743 to your computer and use it in GitHub Desktop.
Save sheran/1278743 to your computer and use it in GitHub Desktop.
Dump a DBase DBF file to stdout as a CSV file
#!/usr/bin/env python
#
# Dump a DBase DBF file to stdout as a CSV file
#
# Get dbfpy from http://dbfpy.sourceforge.net/ first
#
from dbfpy import dbf
import sys
db = dbf.Dbf(sys.argv[1])
for header in db.header.fields[:-1]:
print header.name+", ",
print db.header.fields[-1].name
for rec in db:
for field in rec.fieldData[:-1]:
print str(field)+", ",
print rec.fieldData[-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment