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 have so far:

import arcpy                                                                               
from arcpy import env  
from arcpy.sa import *
import os

workspace = r"X:\Auftrag\2015\1415154_Armasuisse_GHK\04_Arbeitsordner\VoF\Armasuisse_Vof.gdb"
arcpy.env.workspace = workspace
arcpy.env.scratchworkspace = workspace
arcpy.env.overwriteOutput = True

Inputdaten_txt = "Batchtable"

Attributes = arcpy.ListFields(Inputdaten_txt)
Attribute_List = []
for field in Attributes:

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 script

I'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?

  • 1
    Please replace the picture of your code with a code snippet as text so that it can be searched as well as copy/pasted for testing.
    – PolyGeo
    Dec 29, 2015 at 11:05
  • Please expand upon "SearchCursor object at 0x14A522A0"...is this coming back in an error? the console? as a result?
    – MaryBeth
    Dec 29, 2015 at 13:04
  • Can you post the line of code that causes the error, as well as the entire error? Dec 29, 2015 at 16:56

1 Answer 1


Here are two different ways in which you could accomplish the task.

You could create an empty list for each attribute and append to these lists in your search cursor for loop.

Temp =[]
with arcpy.da.SearchCursor(Inputdaten_txt, Attribute_List) as cursor:
    for row in cursor:

A different way to would be to create a single list variable that contains lists within it of each attributes value

lists =[]
for i in range(0,len(Attribute_List)):
with arcpy.da.SearchCursor(Inputdaten_txt, Attribute_List) as cursor:
    for row in cursor:
        for i in range(0,len(row)):

print lists[0] # this should print out a list of all of the OBJECTID values in your table "Batchtable"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.