generate functionThu, 27 Apr 2023

1. Once open a file into the variable "filetxt" generate a function to search the identifier: "Resultados de la optimizacion", and read information spread by tabs in the next 48 lines only

filetxt = open(path, 'r') def get_optimization_results(filetxt): results = [] pattern = 'Resultados de la optimizacion' for line in filetxt: if line.startswith(pattern): results = [next(filetxt) for x in range(48)] return results

Questions about programming?Chat with your personal AI assistant