I want to read a.txt file which containing more than 25000 lines for that proposes I have written a python program, but it provided (output)only 490 lines can any one modify my program?
f = open('file2.txt','r')
for line in f:
data=list(map(float,line.strip().split()))
y=[]
y.append(data[2])
print(y)
If you want the 3rd float per line into the y
list, you're looking for something like
y = []
with open("file2.txt") as f:
for line in f:
data = [float(x) for x in line.strip().split()]
y.append(data[2])
print(y)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.