[GIS] How to copy entire fields into a python list

arcpyfields-attributeslistpython

I'am trying to find a way to copy entire fields(columns) in a feature class attribute table as lists inside a master list (python).

To illustrate it, consider the table below:

enter image description here

So the list should look something like this:

talukas = [[26190, 26191, 26192, 26193, 26194, 26195, ...], 
   [Tharad, Vadgam, Vav, Amod, Ankleshwar, Bharuch, ...],
    [None, None, None, None, None, Ahmedabad Ciy, ...] ]                                                   

I was trying this,

    features = [[row.getValue(f) for f in fields] for row in arcpy.SearchCursor(fc)]

but this gives the entire row values in sub-list and not column value.

Best Answer

Close!

features = [[row.getValue (field.name) for row in arcpy.SearchCursor (fc)] for field in arcpy.ListFields (fc)]

With da:

features = [[r[0] for r in arcpy.da.SearchCursor (fc, field.name)] for field in arcpy.ListFields (fc)]