ListFiles (arcpy)
Récapitulatif
Returns a list of files in the current workspace based on a query string. Specifying search conditions can be used to limit the results.
Discussion
The workspace environment must be set first before using several of the List functions, including ListDatasets, ListFeatureClasses, ListFiles, ListRasters, ListTables, and ListWorkspaces.
Syntaxe
ListFiles ({wild_card})
Paramètre | Explication | Type de données |
wild_card |
Un caractère générique limite les résultats renvoyés. Si aucun caractère générique n'est spécifié, toutes les valeurs sont renvoyées. | String |
Type de données | Explication |
String |
A list of files. |
Exemple de code
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)
Thèmes connexes
9/12/2013