Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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:
            ........
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #loop #opening #file #directory
ADD COMMENT
Topic
Name
7+7 =