GeoEco.DataManagement.Directories.Directory.FindAndCreateArcGISTable
- classmethod Directory.FindAndCreateArcGISTable(directory, workspace, table, directoryField, wildcard='*', searchTree=False, mustBeEmpty=False, mustNotBeEmpty=False, minDateCreated=None, maxDateCreated=None, minDateModified=None, maxDateModified=None, relativePathField=None, dateCreatedField=None, dateModifiedField=None, parsedDateField=None, dateParsingExpression=None, unixTimeField=None, maxPathLength=None, overwriteExisting=False)
Finds subdirectories within a directory and creates a table that lists them.
On Windows, this function makes no distinction between hidden and visible directories. Hidden directories are traversed and handled just like visible directories.
Directories are returned in an arbitrary order determined by the operating system and the search algorithm.
Requires: ArcGIS Pro 3.2.0 or later or ArcGIS Server equivalent to ArcGIS Pro 3.2.0 or later.
- Parameters:
directory (
str) – Directory to search. Minimum length꞉ 1. Must exist.workspace (
str) – Workspace in which the table should be created. Minimum length꞉ 1. Must exist.table (
str) –Name of the table to create.
If the output workspace is a directory (rather than a database) a dBASE table (.dbf file) will be created. It is not possible to create other types of tables in the file system (e.g. comma or space-delimited text files). This restriction is imposed by the ArcGIS
CreateTable()tool, which is used to create the table. If you omit an extension from the table name, .dbf will be added automatically. If you specify another extension, such as .csv or .txt, it will be replaced with .dbf.Minimum length꞉ 1.
directoryField (
str) – Name of the field to receive absolute paths to the directories that were found. Minimum length꞉ 1.wildcard (
str, optional) –UNIX-style “glob” wildcard expression specifying the directories to find.
The glob syntax supports the following patterns:
?- matches any single character*- matches zero or more characters[seq]- matches any single character inseq[!seq]- matches any single character not inseq
seqis one or more characters, such asabc. You may specify character ranges using a dash. For example,a-z0-9specifies all of the characters in the English alphabet and the decimal digits0through9.You may specify subdirectories in the glob expression. For example, the expression
cruise*/sst*will find all paths beginning with sst that are contained in directories beginning with cruise.The operating system determines whether
/or\is used as the directory separator. On Windows, both will work. On Linux,/must be used.The operating system determines if matching is case sensitive. On Windows, matching is case-insensitive. On Linux, matching is case-sensitive.
Minimum length꞉ 1.
searchTree (
bool, optional) – If True, subdirectories will be searched.mustBeEmpty (
bool, optional) – If True, only empty directories will be found.mustNotBeEmpty (
bool, optional) – If True, only non-empty directories will be found.minDateCreated (
datetime, optional) – Minimum creation date, in the local time zone, of the directories to find, as reported by the operating system. If provided, only directories that were created on or after this date will be found. You may provide a date with or without a time. If you do not provide a time, it is assumed to be midnight.maxDateCreated (
datetime, optional) – Maximum creation date, in the local time zone, of the directories to find, as reported by the operating system. If provided, only directories that were created on or before this date will be found. You may provide a date with or without a time. If you do not provide a time, it is assumed to be midnight.minDateModified (
datetime, optional) – Minimum modification date, in the local time zone, of the directories to find, as reported by the operating system. If provided, only directories that were modified on or after this date will be found. You may provide a date with or without a time. If you do not provide a time, it is assumed to be midnight.maxDateModified (
datetime, optional) – Maximum modification date, in the local time zone, of the directories to find, as reported by the operating system. If provided, only directories that were modified on or before this date will be found. You may provide a date with or without a time. If you do not provide a time, it is assumed to be midnight.relativePathField (
str, optional) –Name of the field to receive paths of the directories that were found, relative to the database or directory that contains the output table. For example, if the path to the table is:
C:\Data\Files\FoundFiles.dbf
the relative paths for the directories:
C:\Data\Files\Group1\d1 C:\Data\Files\d1 C:\Data\d1 C:\d1 D:\d1 \\MyServer\Data\d1
would be:
Group1\d1 d1 ..\d1 ..\..\d1 D:\d1 \\MyServer\Data\d1
If the table is in a file geodatabase:
C:\Data\Files\FileInfo.gdb\FoundFiles
the relative paths would be:
..\Group1\d1 ..\d1 ..\..\d1 ..\..\..\d1 D:\d1 \\MyServer\Data\d1
Minimum length꞉ 1.
dateCreatedField (
str, optional) – Name of the field to receive the creation dates of the directories that were found. Minimum length꞉ 1.dateModifiedField (
str, optional) – Name of the field to receive the modification dates of the directories that were found. Minimum length꞉ 1.parsedDateField (
str, optional) – Name of the field to receive dates parsed from the paths of the directories that were found. You must also specify a date parsing expression. Minimum length꞉ 1.dateParsingExpression (
str, optional) –Expression for parsing dates from the paths of the directories that were found. The expression will be ignored if you do not also specify a field to receive the dates or the equivalent UNIX time.
The expression is a standard Python Regular Expression Syntax with additional codes for matching fragments of dates:
%d- Day of the month as a decimal number (range:01to31)%H- Hour (24-hour clock) as a decimal number (range:00to23)%j- Day of the year as a decimal number (range:001to366)%m- Month as a decimal number (range:01to12)%M- Minute as a decimal number (range:00to59)%S- Second as a decimal number (range:00to61)%y- Year without century as a decimal number (range:00to99)%Y- Year with century as a decimal number (range:0001to9999)%%- A literal%characterA date is parsed from a path as follows:
The date fragment codes in your expression are replaced by regular expression groups to produce a true regular expression. For example, if your expression is
%Y_%m_%d, it is converted to the regular expression(\d\d\d\d)_(\d\d)_(\d\d).re.search()is invoked to find the first occurrence of the regular expression in the path. The search proceeds from left to right.If an occurrence is found, the regular expression groups are extracted and
time.strptime()is invoked to parse a date from the groups.
Notes:
Your expression must include at least one date fragment code, but it need not include all of them. If a particular code is missing, the following default values will be used: year
1900, month01, day01, hour00, minute00, second00.You cannot specify a given date fragment code more than once.
You cannot specify date fragment codes that might conflict. For example, you cannot specify both
%jand%dbecause this could result in conflicting values for the day.For
%y, values00to68are interpreted as years2000through2068, while69through99are interpreted as years1969through1999.Remember that the entire path is searched for your expression, from left to right. The first occurrence of it may be in the parent directories.
The date fragment codes are case-sensitive.
If the underlying storage format can hold the time as well as the date in a single field, the time will be stored along with the date. If the table cannot hold the time and date in a single field, then only the date will be stored. This is the case, for example, with dBASE III and IV tables (.dbf files), often used by ArcGIS.
The timezone of the parsed date is assumed to be UTC.
Example:
The expression:
%Y.*%j
will parse dates from a series of directories similar to those maintained by NASA PO.DAAC for holding GOES SST data, in which the date and day of year define the subdirectory structure:
C:\SST\goes10-12\2005\001 C:\SST\goes10-12\2005\002 C:\SST\goes10-12\2005\003 ...
Minimum length꞉ 1.
unixTimeField (
str, optional) –Name of the field to receive dates, in “UNIX time” format, parsed from the paths of the directories that were found. You must also specify a date parsing expression.
UNIX times are 32-bit signed integers that are the number of seconds since 1970-01-01 00:00:00 UTC. This tool assumes the date that was parsed is in the UTC timezone. The UNIX time values produced by this tool do not include leap seconds; this tool assumes that a regular year is 31536000 seconds and a leap year is 31622400 seconds.
Minimum length꞉ 1.
maxPathLength (
int, optional) – Maximum length of a path for this operating system. This value is used to specify the width of the field that is created. You should provide a value only if the underlying database requires that you specify a width for string fields. If you provide a value that is too small to hold one of the paths that is found, this function will fail when it finds that path. Minimum value꞉ 1.overwriteExisting (
bool, optional) – If True, the output table will be overwritten, if it exists. If False, aValueErrorwill be raised if the output table exists.
- Returns:
Table that was created.
- Return type: