ListFiles (arcpy)

Resumen

Returns a list of files in the current workspace based on a query string. Specifying search conditions can be used to limit the results.

Debate

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

Sintaxis

ListFiles ({wild_card})
ParámetroExplicaciónTipo de datos
wild_card

El comodín limita los resultados que se obtienen. Si no se especifica ningún comodín, se obtienen todos los valores.

String
Valor de retorno
Tipo de datosExplicación
String

A list of files.

Ejemplo de código

ListFiles example

Copy a list of CSV files to dBASE format.

import arcpy
from arcpy import env
import os

env.workspace = "c:/temp"

# Copy each file with a .csv extension to a dBASE file
#
for file in arcpy.ListFiles("*.csv"):
    # Use splitext to set the output table name
    #
    dbfFile = os.path.splitext(file)[0] + ".dbf"
    arcpy.CopyRows_management(file, dbfFile)

Temas relacionados

9/11/2013