0

This is a data.txt file I want to read:

####
x y
0 1
1 2
3 4

I want to read the data from line 3. My codes is shown following:

x = []
y = []
with open('./data.txt', 'r') as f:
    num = 0
    for line in f:
        num += 1
        if num>=3:
            lines = line.split(' ')
            x.append(float(lines[0]))
            y.append(float(lines[1]))
print(x)
print(y)

Are there more effective method to read this file without any python packages?

zephyrus
  • 1
  • 1

0 Answers0