0

i am encountering an issue with my program, i would like the program to recognize string from a txt using two columns, then to put the strings of the txt in a list with the name of rows in the two columns, i don't know how to create list automatically now, but i still want to make a program that everything he recognize in the txt is put in a list.

link = "excelfilett.txt"
file = open(link, "r")
frames_path = []
is_count_frames_path = False
for line in file:
    if "[Routing Paths]" in line:
        is_count_frames_path = True
    if is_count_frames_path== True:
        for row in df_frame_array_load["[Name]"]:
            if row in line:
                a = line[0:4]
                a = list(a)
            if "[EthernetComNeed]" in line:
                break
        for row in df_frame_array_load["[Name2]"]:
            if row in line:
                a = line[0:4]
                a = list(a)
            if "[EthernetComNeed]" in line:
                break
    if "[EthernetComConfig]" in line:
        break
print(a)

But it only gives me this:

['F', 'L', '_', '9']

While i want something like:

['FL_1', 'FL_1', 'FL_2', 'FL_9']

Any ideas on how to do this?

JoNeen
  • 15
  • 1
  • 8
  • Welcome to StackOverflow! To help readers understand your question can you give an example snippet of the contents in "excelfilett.txt"? Because doing so will help readers understand the desired output that you are expecting and figure out the issue you are having. – kevins_1 Nov 21 '18 at 16:31
  • shouldn't you use readline()? like this one: https://stackoverflow.com/questions/3277503/how-to-read-a-file-line-by-line-into-a-list?noredirect=1 – Bartek Malysz Nov 21 '18 at 16:40

0 Answers0