ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

ListDatasets

  • Summary
  • Discussion
  • Syntax
  • Code sample

Summary

Returns a list of datasets in the current workspace. Search conditions can be specified for the dataset name and dataset type to limit the list that is returned.

Discussion

The workspace environment must be set before using several of the list functions, including ListDatasets, ListFeatureClasses, ListFiles, ListRasters, ListTables, and ListWorkspaces.

Syntax

ListDatasets ({wild_card}, {feature_type})
ParameterExplanationData Type
wild_card

Limits the results returned. If a value is not specified, all values are returned. The wildcard is not case sensitive.

SymbolDescriptionExample

*

Represents zero or more characters.

Te* finds Tennessee and Texas.

String
feature_type

The dataset type that will limit the results returned by the wild_card argument. The following are valid dataset types:

  • Coverage —Only coverages.
  • Feature —Coverage or geodatabase dataset, depending on the workspace.
  • GeometricNetwork —Only geometric network datasets.
  • Mosaic —Only mosaic datasets.
  • Network —Only network datasets.
  • ParcelFabric —Only parcel fabric datasets.
  • Raster —Only raster datasets.
  • RasterCatalog —Only raster catalog datasets.
  • Schematic —Only schematic datasets.
  • Terrain —Only terrain datasets.
  • Tin —Only TIN datasets.
  • Topology —Only topology datasets.
  • All —All datasets in the workspace. This is the default value.

(The default value is All)

String

Return Value

Data TypeExplanation
String

A list containing dataset names returned from the function, limited by the wildcard and feature type arguments.

Code sample

ListDatasets example

List feature dataset names that start with C.

import arcpy

arcpy.env.workspace = "c:/data"

# Print to the Interactive window all the feature datasets in the
#   workspace that start with the letter C.
datasets = arcpy.ListDatasets("C*", "Feature")

for dataset in datasets:
    print(dataset)
ListDatasets example 2

List feature dataset names that start with c or f, start with letters except c, or contain both c and f.

import arcpy
arcpy.env.workspace = 'c:/data'

# Print to the interactive window all the feature datasets in the
#   workspaces that start with the letter c or f.
datasets1 = list(set(arcpy.ListDatasets("c*", "Feature")) |
                 set(arcpy.ListDatasets("f*", "Feature")))
print(datasets1)

#   workspaces that start with the letters except c
datasets2 = list(set(arcpy.ListDatasets("*", "Feature")) -
                 set(arcpy.ListDatasets("c*", "Feature")))
print(datasets2)

#   workspaces that contain both the letter c and f
datasets3 = list(set(arcpy.ListDatasets("*c*", "Feature")) &
                 set(arcpy.ListDatasets("*f*", "Feature")))
print(datasets3)

Related topics

  • Create lists of data
  • Walk

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal