def parse_stdout_file(curr_timestep=0, stdout_filename="test.txt", debug=False): """ :param curr_timestep: first timestep from config :param stdout_filename: file to parse (test.txt) :param debug: whether or not we write an additional file that's full of the matched lines :return: array of lines of interest """ died_of_coinfection = "died of CoInfection" state_active_symptomatic = "infectionstatechange TBActivation " filtered_lines = [] update_time = "Update(): Time:" time = 0 with open(stdout_filename) as logfile: for line in logfile: if update_time in line: time += 1 elif died_of_coinfection in line: new_line = sft.add_time_stamp(time, line) filtered_lines.append(new_line) elif state_active_symptomatic in line: new_line = sft.add_time_stamp(time, line) filtered_lines.append(new_line) if debug: with open("filtered_lines.txt", "w") as outfile: outfile.writelines(filtered_lines) return filtered_lines
def parse_stdout_file(curr_timestep=0, stdout_filename="test.txt", debug=False): """ :param curr_timestep: first timestep from config :param stdout_filename: file to parse (test.txt) :param debug: whether or not we write an additional file that's full of the matched lines :return: array of lines of interest """ new_infection_state = "SetNewInfectionState" filtered_lines = [] update_time = "Update(): Time:" incubation_timer = "LifeCourseLatencyTimerUpdate" time = 0 with open(stdout_filename) as logfile: for line in logfile: if update_time in line: time += 1 elif new_infection_state in line: new_line = sft.add_time_stamp(time, line) filtered_lines.append(new_line) elif incubation_timer in line: new_line = sft.add_time_stamp(time, line) filtered_lines.append(new_line) if debug: with open("filtered_lines.txt", "w") as outfile: outfile.writelines(filtered_lines) return filtered_lines
def parse_stdout_file(curr_timestep=0, stdout_filename="test.txt", debug=False): """ :param curr_timestep: first timestep from config :param stdout_filename: file to parse (test.txt) :param debug: whether or not we write an additional file that's full of the matched lines :return: array of lines of interest """ expose = "Expose: Individual" filtered_lines = [] update_time = "Update(): Time:" time = 0 with open(stdout_filename) as logfile: for line in logfile: if update_time in line: time += 1 if expose in line: ind = int(sft.get_val("Individual ", line)) if ind <= 100: # do not look at imported people new_line = sft.add_time_stamp(time, line) filtered_lines.append(new_line) if debug: with open("filtered_lines.txt", "w") as outfile: outfile.writelines(filtered_lines) return filtered_lines
def parse_stdout_file(curr_timestep=0, stdout_filename="test.txt", debug=False): """ :param curr_timestep: first timestep from config :param stdout_filename: file to parse (test.txt) :param debug: whether or not we write an additional file that's full of the matched lines :return: an array of filtered lines """ update_infectiousness = "UpdateInfectiousness Individual" update_time = "Update(): Time:" time = 0 filtered_lines = [] with open(stdout_filename) as logfile: for line in logfile: if update_time in line: time += 1 if update_infectiousness in line: new_line = sft.add_time_stamp(time, line) filtered_lines.append(new_line) if debug: with open("filtered_lines.txt", "w") as outfile: outfile.writelines(filtered_lines) return filtered_lines