I'n trying to convert a dbf file to a csv file(or anything else really). I found this on the interwebs but I get an error
import csv
from dbfpy import dbf
import sys
dbf_fn = 'in.dbf'
csv_fn = 'out.csv'
in_db = dbf.Dbf(dbf_fn)
out_csv = csv.writer(open(csv_fn, 'wb'))
names = []
for field in in_db.header.fields:
names.append(field.name)
out_csv.writerow(names)
for rec in in_db:
out_csv.writerow(rec.fieldData)
in_db.close()
error:
Traceback (most recent call last):
File "piotest.py", line 9, in <module>
out_csv = csv.writer(open(csv_fn, 'wb'))
AttributeError: 'module' object has no attribute 'writer'
I'm not sure which module this is refering to?