Answers for "how to read from a folder in for loop in pyrhon"

0

python loop opening file from directory

basepath = "pathtodir/DataFiles/"
for filename in os.listdir(basepath):
    if filename.endswith(".log"): 
        print(os.path.join("./DataFiles", filename))

        with open(basepath + filename) as openfile:    
            for line in openfile:
            ........
Posted by: Guest on March-31-2020

Code answers related to "how to read from a folder in for loop in pyrhon"

Python Answers by Framework

Browse Popular Code Answers by Language