Feb-06-2018, 07:06 PM
Hi All,
I am making a script to find a file with certain extension.
here is my code
I have two major problems
1- it is very slow as reference mention :
Note: Using the “**” pattern in large directory trees may consume an inordinate amount of time.
2- it sometimes fail to chat files if they start with "." , as reference : If the directory contains files starting with . they won’t be matched by default. For example, consider a directory containing card.gif and .card.gif:
[inline]>>> import glob
>>> glob.glob('*.gif')
['card.gif']
>>> glob.glob('.c*')
['.card.gif'][/inline]
ref for the issues : https://docs.python.org/3.7/library/glob...#glob.glob
I am asking for a better code that can fit my needs. any suggestions?
I am making a script to find a file with certain extension.
here is my code
1 2 3 4 |
import glob searchCriteria = myDir + r '\**\*.csv' print (searchCriteria) istpFiles = glob.glob(searchCriteria,recursive = True ) |
1- it is very slow as reference mention :
Note: Using the “**” pattern in large directory trees may consume an inordinate amount of time.
2- it sometimes fail to chat files if they start with "." , as reference : If the directory contains files starting with . they won’t be matched by default. For example, consider a directory containing card.gif and .card.gif:
[inline]>>> import glob
>>> glob.glob('*.gif')
['card.gif']
>>> glob.glob('.c*')
['.card.gif'][/inline]
ref for the issues : https://docs.python.org/3.7/library/glob...#glob.glob
I am asking for a better code that can fit my needs. any suggestions?