line_2_data=Noneline_3_data=Noneline_4_data=Nonewithopen('some_file.txt')asfile:# iterate line by line
forlineinfile:ifthis_line_is_what_i_want(line):line_2_data=extract_data_using_regex_or_split_string(line)elifthis_line_is_what_i_want_too(line):line_3_data=extract_this_data_too(line)...
if index of the line in the file is what you are looking for.
View all comments
1
u/WinterMelonToufu Feb 23 '20
Iterate with a counter to find the lines, split string/regex to extract the data you need from the specific line.