In my code I am creating a table with some fields. The fields should be filled with 0 (Datatype of the fields are LONG or DOUBLE). I want to fill them because afterwards I want to update the values. But without a row with default values, I can't update the values.
tb_path = r'C:\Users\a48384\Desktop\00_ArcGis\Daten'
tb_name = '\netzplan'
arcpy.CreateTable_management(tb_path,tb_name)
tbNetzplan = r'c:\users\a48384\desktop\00_arcgis\daten\netzplan'
#names of the fields which will be added
fn_LEN_NS_FREI = "LEN_NS_FREI"
fn_NS_VERKAB_GRAD = "NS_VERKAB_GRAD"
fn_LEN_NS_KAB = "LEN_NS_KAB"
fn_ANZ_NS_KVS = "ANZ_NS_KVS"
fn_ANZ_NS_KVS_BS = "ANZ_NS_KVS_BS"
fn_ANZ_NS_KVS_NBS = "ANZ_NS_KVS_NBS"
fn_ANZ_NS_KVS_NULL = "ANZ_NS_KVS_NULL"
#Adding fields to the table
arcpy.AddField_management(tbNetzplan, fn_LEN_NS_FREI, "Double")
arcpy.AddField_management(tbNetzplan, fn_NS_VERKAB_GRAD, "INTEGER")
arcpy.AddField_management(tbNetzplan, fn_LEN_NS_KAB, "Double")
arcpy.AddField_management(tbNetzplan, fn_ANZ_NS_KVS, "INTEGER")
arcpy.AddField_management(tbNetzplan, fn_ANZ_NS_KVS_BS, "INTEGER")
arcpy.AddField_management(tbNetzplan, fn_ANZ_NS_KVS_NBS, "INTEGER")
arcpy.AddField_management(tbNetzplan, fn_ANZ_NS_KVS_NULL, "INTEGER")
Now I would like to add a row with default values. But I don't know how... Afterwards the values are going to be updated:
cur = arcpy.UpdateCursor(tbNetzplan)
for row in cur:
row.insertValue(fn_LEN_NS_FREI, VALUE1)
row.setValue(fn_NS_VERKAB_GRAD, VALUE2))
row.setValue(fn_LEN_NS_KAB, VALUE3)
row.setValue(fn_ANZ_NS_KVS, VALUE4)
row.setValue(fn_ANZ_NS_KVS_BS, VALUE5)
row.setValue(fn_ANZ_NS_KVS_NBS, VALUE6)
row.setValue(fn_ANZ_NS_KVS_NULL, VALUE7)
cur.updateRow(row)
arcpy.da.InsertCursor
with a column list that only includes your required columns, your work is done.