0

Basically I have a some text files that vary in length. All txt files have some number of lines with just sentences describing the results and such. then after the lines of text, there are two columns with numbers I just want to be able to append the number values to a list and then do whatever. So the txt file when you open it looks like :

sentence

another sentence

a few more sentence

1.1 2.2

3.3 4.4

What I have so far is

File1 = open(r"C:\Users\Location of File)

list =[]
lines = File1.readlines()
for column in File1:
    list.append(float(column[1]))

print (list)

but then I get an empty list with nothing in it.

  • Are you looking for this: https://stackoverflow.com/questions/46258499/read-the-last-line-of-a-file-in-python – AshlinJP Feb 05 '20 at 23:10
  • No that does not help - If I read the "last line" it will literally read the last row of numbers in my txt file. I want to be able to skip the sentences and then append the numbers to a list. So in my post when I print list I should get [2.2, 4.4...] – posh8593 Feb 05 '20 at 23:29

0 Answers0