I have a .csv file that I am reading in using python 2.5 in ArcGIS 9.3.1 and am having some issues with outputing the first line of the output shapefile. It seems that the code runs OK but when I check it the first group of ids (#1) does not show up in the output but the last line of ids shows up twice.Can't figure out why the first row is being omitted. An extract of the python script I am using is as follows:
for line in fileinput.input(infile): # Open the input file
# Create a list of input values and set the point properties.
values = string.split(line,",") #comma delimited
#field values
pnt.id = values[0] #point ID (not FID or OID)
pnt.x = values[1] #x ak state plane 4 coord
pnt.y = values[2] #y ak state plane 4 coord
pnt.z = values[3] #z (TVD) true vertical depth
#pnt.m = values[4] #m (MD) measured depth
#print "values: " + str(pnt.id),str(pnt.x),str(pnt.y),str(pnt.z)
if ID == -1: # initial state
ID = pnt.id
# Add the point to the feature's array of points
# If the ID has changed create a new feature
if ID != pnt.id:
# Create a new row or feature, in the feature class
feat = cur.NewRow()
# Set the geometry of the new feature to the array of points
feat.shape = lineArray
# Insert the feature
feat.setvalue("ID",pnt.id)
feat.setvalue("Z",pnt.z)
cur.InsertRow(feat)
lineArray.RemoveAll()
#add point to point array
if pnt.id != "0.100000E+31":
lineArray.add(pnt)
ID = pnt.id
# Add the last feature
feat = cur.NewRow()
feat.shape = lineArray
feat.setvalue("ID",pnt.id)
feat.setvalue("Z",pnt.z)
cur.InsertRow(feat)