How to load feature classes from csv list into Contents

520
0
12-26-2019 11:02 AM
MalcolmLittle1
New Contributor II

Hello,

I have a csv file with a list of specific IDs. These IDs relate to the name of feature classes that I want to bring into Contents in my ArcPro project. I am trying to use Python code to do so, but nothing happens when I run the following:

import pandas, os, arcpy
gdb = "D:\SphereRoutesStops\S2011_SchoolAstudentsAHW_RS75m_ByStudent_ByDay.gdb"
walk = arcpy.da.Walk(gdb)

df = pandas.read_csv(r'C:\Users\Little\Desktop\Surveys_AgesGenders.csv')
StudID = df['SID']

for root, dirs, files in walk:

   for fc in files:

      if fc.startswith(StudID.values):

         arcpy.MakeFeatureLayer_management(os.path.join(root,fc))

The csv file is laid out like so:

The gdb contains feature classes that start with the IDs in question:

Essentially, I would like to place all feature classes that start with the IDs contained within the csv file into my current map contents. Problem is, when I run the above code in the Python console in ArcPro, nothing happens - no errors, and nothing gets added to Contents.

Tags (2)
0 Kudos
0 Replies