List Excel File Sheet Names as an Input Parameter for Custom tools in ArcGIS Pro with ArcPy & Pandas

Table of Contents

The Video

Introduction

The Excel to Table Geoprocessing tool takes an Excel file as a parameter and then exposes the sheet names for the that file as a selection list in another parameter. In this blog post we will see how to use pandas and ArcPy in the custom tool Validator to achieve the same functionality if required for a bespoke workflow.

ArcGIS Pro Definition Query Masterclass with ArcPy & Python

Unlock the power of Definition Queries in ArcGIS Pro through this comprehensive course that dives deep into the intricacies of managing and utilizing definition queries with spatial data using ArcPy and Python scripting. Definition Queries provide a dynamic way to filter and display specific subsets of your data, enabling you to create more insightful maps and analyses. In this course, we will focus exclusively on Definition Queries, covering their creation, modification, and application through hands-on exercises and real-world scenarios. Accredited by the Association for Geographic Information (AGI) for 1 CPD point.

Custom Tool Parameters

For this example we will use the two required parameters, your custom tool might have more parameters. The first parameter prompts the user to add an Excel file (.xlsx) as an input. The second parameter is a string that will represent a dropdown list of the available sheet names from the input Excel file. 

List Excel Sheet Names Parameters in Custom Tool in ArcGIS Pro

Custom Tolol Validation

At the top of the validation we import the pandas module. We the add code to the updateParameters function. This function is called whenever an input parameter is updated. If a user has selected an input Excel file, then pandas will access that file and set the dropdown choice list for the second parameter (Sheet Name) to the list all sheet names from the Excel file.

Get Excel Sheet Names tool Validation for ArcGIS Pro Custom Tool

Get Excel Sheet Names Input Parameters in Action

Below I have selected an Excel file as the first user input. The tool validation kicks in an pandas grabs the list of sheet names from the file and ArcPy presents that list as a dropdown for the second parameter.

Get Excel Sheet Names in ArcGIS Pro with ArcPy & Pandas in Action

Mastering ArcGIS Pro ArcPy Search, Insert, & Update Cursors

Unlock the full potential of ArcPy Cursors with our intensive and in-depth course. Designed for GIS professionals, analysts, and enthusiasts, this course delves into the intricacies of Search, Insert, and Update Cursors in the ArcPy library, empowering you to manipulate and manage spatial data with precision and efficiency.

ArcPy Cursors enable you to streamline your GIS workflows, automate repetitive tasks, and witness the full potential of spatial data manipulation in ArcGIS Pro.

Leave a Comment