Next / Previous / Contents / Shipman's homepage

88. dbfstruct: Display the structure of a dBASE V file

This script takes a dBASE V .dbf file and writes a report of the file's characteristics including the column (field) structure.

88.1. Prologue

Here is the beginning of the dbfstruct script. It starts with a line to make it self-executing on Unix systems (the “pound-bang” line), followed by a pointer back here to the documentation.

dbfstruct
#!/usr/bin/env python
#================================================================
# dbfstruct:  Display the structure of a dBASE .dbf file.
# For documentation, see:
#   http://www.nmt.edu/~shipman/z/ibp/doc/iband7/ims/
#----------------------------------------------------------------

Two modules are imported. The standard Python sys module gives us access to the command line arguments and standard I/O streams. The dbf module is described in Section 90, “The dbfpy package for reading dBASE V files”.

dbfstruct
#================================================================
# Imports
#----------------------------------------------------------------

import sys
from dbf import *