import struct, datetime, decimal, itertools from collections import namedtuple FI = namedtuple('FieldInfo', ('name', 'typ', 'size', 'deci', 'fmt', 'fmtsiz', 'keep', 'seekme')) def dbfreader(f, names, nullreplace=None): """Returns an iterator over records in a Xbase DBF file. The first row returned contains the field names. The second row contains field specs: (type, size, decimal places). Subsequent rows contain the data records. If a record is marked as deleted, it is skipped. names is the field names to extract. The value of nullreplace is used with data of type 'N' as a replacement for '\0'. File should be opened for binary reads. """ # See DBF format spec at: # numrec, lenheader = struct.unpack('