AnsweredAssumed Answered

Running into trouble adding data to a table

Question asked by Sycosys on Oct 10, 2012
Latest reply on Oct 10, 2012 by Sycosys
Edit.. Well ****.. i figured it out.

looks like this bit is important

rows.insertRow(row)


 if count == 0:   print "uh oh"   rows = arcpy.InsertCursor("C:/Users/atimpson/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Temp_Stats")   x = 0   while x != 1:    row = rows.newRow()    row.Frequency = 0    rows.insertRow(row)    x = 1   arcpy.Append_management(["C:/Users/atimpson/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Temp_Stats"], "C:/Users/atimpson/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Stats", "TEST", "", "")   arcpy.Delete_management("C:/Users/atimpson/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Temp_Stats")   del row, rows


Hello,

I am doing some data queries and statistics on a feature class and exporting the summary statistics to be appended to a master table.
The problem i am trying to work around is that if there are no results in the query, then there are no summary statistics and an empty table.

What i am trying to do is, any time there are zero rows in a summary table, add placeholder "0s" to that empty table so that when the append operation happens i see a new row with 0. My attempt at this is giving my a 999999 error and im not sure what to do.

rows = arcpy.InsertCursor("C:/Users/atimpson/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Temp_Stats") x = 0 while x != 1:  row = rows.newRow()  row.Frequency = 0  row.Shape_Length = 0  x = 1



Here is the main body so far so you can see this above snip in context
 try:   arcpy.SelectLayerByAttribute_management ("Testing", "NEW_SELECTION", " [PRESSURE1] = 0 and [CL_MAOP] = 4 ")  arcpy.Statistics_analysis("Testing", "C:/Users/atimpson/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Stats", [["Shape_Length", "SUM"]])   arcpy.SelectLayerByAttribute_management ("Testing", "NEW_SELECTION", " [PRESSURE1] = 0 and [CL_MAOP] = 2 ")  arcpy.Statistics_analysis("Testing", "C:/Users/atimpson/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Temp_Stats", [["Shape_Length", "SUM"]])  count = int(arcpy.GetCount_management("Temp_Stats").getOutput(0))  if count == 0:   print "uh oh"   rows = arcpy.InsertCursor("C:/Users/atimpson/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Temp_Stats")   x = 0   while x != 1:    row = rows.newRow()    row.OBJECTID = 1    row.Frequency = 0    row.Shape_Length = 0    x = 1   arcpy.Append_management(["C:/Users/atimpson/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Temp_Stats"], "C:/Users/atimpson/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Stats", "TEST", "", "")   arcpy.Delete_management("C:/Users/atimpson/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Temp_Stats")   del row, rows  else:   arcpy.Append_management(["C:/Users/atimpson/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Temp_Stats"], "C:/Users/atimpson/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Stats", "TEST", "", "")   arcpy.Delete_management("C:/Users/atimpson/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Temp_Stats")   except:  print("oh ****")


thanks for looking

Outcomes