import arcpy
# optional - to give some output on the terminal
print(":::")
arcpy.env.workspace = "c:/github/arcpy/arcpy_intro/Default.gdb"
feature_classes = arcpy.ListFeatureClasses()
for fc in feature_classes:
print(fc)
print("...")
import arcpy
print(":::")
arcpy.env.workspace = "c:/github/arcpy/arcpy_intro/Default.gdb"
feature_classes = arcpy.ListFeatureClasses()
for fc in feature_classes:
print(fc)
print("...")
import arcpy
print(":::")
arcpy.env.workspace = "c:/github/arcpy/arcpy_intro/Default.gdb"
fields = arcpy.ListFields("bygning")
for field in fields:
print("{0} is a type of {1} with a length of {2}"
.format(field.name, field.type, field.length))
print("...")
import arcpy
print(":::")
arcpy.env.workspace = "c:/github/arcpy/arcpy_intro/Default.gdb"
cursor = arcpy.SearchCursor(
"c:/github/arcpy/arcpy_intro/Default.gdb/bygning",
fields="bygningsnummer",
where_clause="bygningsnummer = 20239077")
row = cursor.next()
while row:
print(row.getValue("bygningsnummer"))
row = cursor.next()
print("...")
import arcpy
print(":::")
arcpy.env.workspace = "c:/github/arcpy/arcpy_intro/Default.gdb"
inFeatures = "bygning"
fieldName = "RES_capacity"
fieldPrecision = 9
fieldAlias = "capacity"
arcpy.AddField_management(inFeatures,
fieldName,
"LONG",
fieldPrecision,
field_alias=fieldAlias,
field_is_nullable="NULLABLE")
print("...")
import arcpy
print(":::")
arcpy.env.workspace = "c:/github/arcpy/arcpy_intro/Default.gdb"
cursor = arcpy.UpdateCursor(
"c:/github/arcpy/arcpy_intro/Default.gdb/bygning",
where_clause="bygningsnummer = 20239077")
row = cursor.next()
while row:
row.setValue("RES_capacity", 1111)
cursor.updateRow(row)
print(row.getValue("bygningsnummer"), end = " ")
print(row.getValue("RES_capacity"))
row = cursor.next()
print("...")