Answers for "how to loop files opening in python"

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 loop files opening in python"

Python Answers by Framework

Browse Popular Code Answers by Language