(In advance i have to say that i'm a a self instructed greenhorn at python)I've vbeen struggling getting a seemingly simple job done:Using a python script, i would like to read through a table which features 27 columns. For each row i want to store the value of each column in a variable, so that i can pass the values to a subsequent script as input parameter.
here's what i got so far:
import arcpy from arcpy import env from arcpy.sa import *import osworkspace = r"X:\Auftrag\2015\1415154_Armasuisse_GHK\04_Arbeitsordner\VoF\Armasuisse_Vof.gdb"arcpy.env.workspace = workspacearcpy.env.scratchworkspace = workspacearcpy.env.overwriteOutput = TrueInputdaten_txt = "Batchtable"Attributes = arcpy.ListFields(Inputdaten_txt)Attribute_List = []for field in Attributes: Attribute_List.append(field.name)with arcpy.da.SearchCursor(Inputdaten_txt, Attribute_List) as cursor: for field in Attribute_List: for row in cursor: OBJECTID = ("{0}".format(row[0])) Temp = ("{0}".format(row[1])) CalculationOption = ("{0}".format(row[2])) ElevationModel = ("{0}".format(row[3])) DrainageNetwork_rainfall = ("{0}".format(row[4])) RelativeDrainageElevation = ("{0}".format(row[5])) Elevation_of_input_drainage_network = ("{0}".format(row[6])) ConstantDrainatePlus = ("{0}".format(row[7])) HydrographFile = ("{0}".format(row[8])) CoordinateFile = ("{0}".format(row[9])) Roughness = ("{0}".format(row[10])) FlowBarrier = ("{0}".format(row[11])) DamFailure = ("{0}".format(row[12])) ContinueCalculationFrom = ("{0}".format(row[13])) ContinueTime = ("{0}".format(row[14])) ContinueInundationAsWaterDepth = ("{0}".format(row[15])) DurationOfSimulation = ("{0}".format(row[16])) SavingIntervall = ("{0}".format(row[17])) OutputSwitch = ("{0}".format(row[18])) MapUnits = ("{0}".format(row[19])) HeightUnits = ("{0}".format(row[20])) drainage_units = ("{0}".format(row[21])) MaximumExchange = ("{0}".format(row[22])) Output = ("{0}".format(row[23])) intermed = ("{0}".format(row[24])) LicenseCode = ("{0}".format(row[25])) Execute = ("{0}".format(row[26])) # continue by calling another python scriptI'm quite sure that i could be done easier, for instance i would like to automatically generate each variable (e.g. var_1 ...var_27) using a loop that goes through a list of these variables obtained with the searchCursor function. But whenever i tried, i got stuck at the point where my variable ends up being a "SearchCursor object at 0x14A522A0" instead of the field value in the table. Can anyone tell me the easiest way to get this task done?
أكثر...
here's what i got so far:
import arcpy from arcpy import env from arcpy.sa import *import osworkspace = r"X:\Auftrag\2015\1415154_Armasuisse_GHK\04_Arbeitsordner\VoF\Armasuisse_Vof.gdb"arcpy.env.workspace = workspacearcpy.env.scratchworkspace = workspacearcpy.env.overwriteOutput = TrueInputdaten_txt = "Batchtable"Attributes = arcpy.ListFields(Inputdaten_txt)Attribute_List = []for field in Attributes: Attribute_List.append(field.name)with arcpy.da.SearchCursor(Inputdaten_txt, Attribute_List) as cursor: for field in Attribute_List: for row in cursor: OBJECTID = ("{0}".format(row[0])) Temp = ("{0}".format(row[1])) CalculationOption = ("{0}".format(row[2])) ElevationModel = ("{0}".format(row[3])) DrainageNetwork_rainfall = ("{0}".format(row[4])) RelativeDrainageElevation = ("{0}".format(row[5])) Elevation_of_input_drainage_network = ("{0}".format(row[6])) ConstantDrainatePlus = ("{0}".format(row[7])) HydrographFile = ("{0}".format(row[8])) CoordinateFile = ("{0}".format(row[9])) Roughness = ("{0}".format(row[10])) FlowBarrier = ("{0}".format(row[11])) DamFailure = ("{0}".format(row[12])) ContinueCalculationFrom = ("{0}".format(row[13])) ContinueTime = ("{0}".format(row[14])) ContinueInundationAsWaterDepth = ("{0}".format(row[15])) DurationOfSimulation = ("{0}".format(row[16])) SavingIntervall = ("{0}".format(row[17])) OutputSwitch = ("{0}".format(row[18])) MapUnits = ("{0}".format(row[19])) HeightUnits = ("{0}".format(row[20])) drainage_units = ("{0}".format(row[21])) MaximumExchange = ("{0}".format(row[22])) Output = ("{0}".format(row[23])) intermed = ("{0}".format(row[24])) LicenseCode = ("{0}".format(row[25])) Execute = ("{0}".format(row[26])) # continue by calling another python scriptI'm quite sure that i could be done easier, for instance i would like to automatically generate each variable (e.g. var_1 ...var_27) using a loop that goes through a list of these variables obtained with the searchCursor function. But whenever i tried, i got stuck at the point where my variable ends up being a "SearchCursor object at 0x14A522A0" instead of the field value in the table. Can anyone tell me the easiest way to get this task done?
أكثر...