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". 2. Into the function generate a table with the next information in the same line than the identifier if it is "solo carga sin EVs" Assign the value: "woEVs", elseif "minima carga requerida" Assign the value: "MinMCS", elseif "maxima carga requerida" Assign the value: "MaxMCS"

def searchidentifier(filetxt): for line in filetxt: if "Resultados de la optimizacion" in line: print(line) return line def search(filetxt): for line in filetxt: if "minima carga requerida" in line: print(line) return line elif "maxima carga requerida" in line: print(line) return line elif "solo carga sin EVs" in line: print(line) return line filetxt = open("00-pwr-baseline.txt", "r") searchidentifier(filetxt) search(filetxt)

Questions about programming?Chat with your personal AI assistant