I have the following type of data in a text file.
15 1
23 0
39 -1
71 -1
79 1
95 1
127 -2
151 2
183 1
191 -1
239 0
247 3
I want to create a 2d list from the text file as follows. I am able to do that with the code given below with the following result
[[15, 1],
[23, 0],
[39, -1],
[71, -1],
[79, 1],
[95, 1],
[127, -2],
[151, 2],
[183, 1],
[191, -1],
[239, 0],
[247, 3]]
The problem is that the file contains millions of such data. What do I do to just copy first say 1000 lines at a time? How can I add the conditional statement into my code.
with open("path.text") as file:
R = [[int(x) for x in line.split()] for line in file]