Walking a directory to process two file types in Python -
after checking , processing particular file type (say typea) in directory, if processed typea file outputs txt file (typeb) how concentrate , process typeb txt file before moving next original file typea processing?
to clarify have directory of logs like...
file1.typea file2.typea file3.typea
when run file1.typea file through function generates txt files in same directory, looking process txt files , grab whatever data need , go next original file type file2.typea @ start of loop , repeat process.
i have code walking directory, seems unnecessary , bit messy directory walk looking txt files after first typea file processed, see below.
for root, subfolders, files in os.walk(path): filename in files: if filename.endswith('.typea'): run_processor_to_txt() root, subfolders, files in os.walk(path): filename in files: if filename.endswith('.txt'): stuff here...
is there tidier way of alternating processing of file types once new files generated through function?
Comments
Post a Comment