Created
October 11, 2011 17:24
-
-
Save sheran/1278743 to your computer and use it in GitHub Desktop.
Dump a DBase DBF file to stdout as a CSV file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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