tf.io.gfile.glob
Stay organized with collections
Save and categorize content based on your preferences.
Returns a list of files that match the given pattern(s).
tf.io.gfile.glob(
pattern
)
The patterns are defined as strings. Supported patterns are defined
here. Note that the pattern can be a Python iteratable of string patterns.
The format definition of the pattern is:
pattern: { term }
term:
'*'
: matches any sequence of non-'/' characters
'?'
: matches a single non-'/' character
'[' [ '^' ] { match-list } ']'
: matches any single
character (not) on the list
c
: matches character c
where c != '*', '?', '\\', '['
'\\' c
: matches character c
character range:
c
: matches character c
while c != '\\', '-', ']'
'\\' c
: matches character c
lo '-' hi
: matches character c
for lo <= c <= hi
Examples:
tf.io.gfile.glob("*.py")
# For example, ['__init__.py']
tf.io.gfile.glob("__init__.??")
# As above
files = {"*.py"}
the_iterator = iter(files)
tf.io.gfile.glob(the_iterator)
# As above
See the C++ function GetMatchingPaths
in
core/platform/file_system.h
for implementation details.
Args |
pattern
|
string or iterable of strings. The glob pattern(s).
|
Returns |
A list of strings containing filenames that match the given pattern(s).
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-01-23 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2024-01-23 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-01-23 UTC."],[],[]]