Hi, just hoping someone can shed some light on the best way to read from a text file. I wish to create a program that will grab out specific words/numbers when chosen. I need to be able to extract data from different fields but also be able to determine if there are any empty entries. I can get it to read the by line, but not by words or numbers.
In the text file I have the words seperated by a , to create the seperate sections. EG
Barry, Crocker, 17, 19, 30
I am using the following code to input the whole line
[def main():
f = open( "Exp_2010_input.txt", "r") # Opening the text file
line = f.readline() # Reading the whole line
while len(line) !=0:
print line
line = f.readline()
main()]
Also, if someone could please explain to me the while len(line) ! =0, it would be greatly appreciated! I think it means that while the line length is not equal to 0, print line. Does the ! mean not?
Thanks in advance! Im just trying to get my head around all of this and its difficult to find good help!
Cheers,
Todd