-1
votes

I am creating a program that reads x,y,z in the format of (1.000 2.000 3.000), first coloumn is x second is y and the third is z. I would like to read this data from this file (hiz.txt) and then call up on them as variables later on. I am looking for about 50-100 rows of this data, and i want my program to keep looking and transferring until it reaches the end.

1
So learn to program, then try to write the program, then if you get stuck come back and we'll help you. - agf

1 Answers

2
votes

I assume by "huge data" you mean the file won't all fit into memory, so you have to go line by line.

I also assume you just want to save up the 50 or so rows you are looking for and that those will fit into memory.

So Like this:

theDataIWant = []

def isThisSomethingIWant(x, y, z):
    return the condition involving ... x ... y ... z ...

for line in open('myfile','r'):
    x, y, z = line.split(" ")
    if isThisSomethingIWant(x, y, z):
        theDataIWant.append( (x, y, z) )