generate functionThu, 27 Apr 2023

1. Open txt files from all the directories from you current directory, once in each directory open the directory "Sample" and the file "Sample.txt" 2. Once open each txt file, search the identifier: "Resultados de la optimizacion", once located read the information that continue in the same line. 3. Read the information from the next 48 lines 4. Finally apply the steps 2 and 3 2 more times

def open_txt_files(input_dir): for root, dirs, files in os.walk(input_dir): for file in files: if file.endswith(".txt"): f = open(os.path.join(root, file), "r") content = f.read() #Your code

Questions about programming?Chat with your personal AI assistant