DIR_PATH = os.path.dirname(os.path.abspath(__file__))
def loop_folder(folder_name):
return
def get_file_details(path):
for files in os.listdir(DIR_PATH):
listOfFiles = os.listdir('.')
for entry in listOfFiles:
if entry != '.DS_Store':
if os.path.isdir(entry):
loop_folder()
elif entry.endswith(".csv"):
print entry
Hello, I want to write a script that loops in a folder and it's sub-folders until it finds a file with .csv and print it.
I want to make a recursion loop function and call it. But I am stuck and I could use some guidance My problem is with the loop function
This will give you all .csv
files in all sub-directories: import os
for dirpath, dirnames, filenames in os.walk("."):
for filename in [f for f in filenames if f.endswith(".csv")]:
#do stuff
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.