python to open dbf?

Discussion created by chrisjcantire on Mar 27, 2013
Latest reply on Mar 27, 2013 by chrisjcantire
hi guys, python novice here, thanks for any help....

have this working so far:

import arcgisscripting
import re
import dbfpy
import sqlite3

# create the geoprocessor object
gp = arcgisscripting.create(9.3)

gp.workspace = "I:\PDtest"

layer1 = raw_input('what is layer1?')
layer1 = layer1 + ".shp"
layer2 = raw_input('what is layer2?')
layer2 = layer2 + ".shp"

# process

layer1 = re.sub('.shp', '', layer1)
layer2 = re.sub('.shp', '', layer2)

final_layer = layer1+"_"+layer2
complete_name = final_layer+".dbf"
gp.Rename_management("temp.dbf", complete_name) runs a point distance analysis on two layers input by the user, and renames the resulting dbf to a combination of the two layer names.  this is pretty basic stuff but I'm new to this; now I want to open that resultant .dbf and use sqlite to interrogate it; I've imported dbfpy but can't seem to get past errors indicating that something is wrong with my dbf syntax....for example...

db = dbf.Dbf(complete_name)
for rec in db:
    print rec

results in 'name dbf is not defined', and several edits to this result in similar problems; what am I doing wrong when trying to open this .dbf?  I seem to have dbfpy in the proper place so that shouldn't be an issue...

thanks very much,