Reputation: 41
I have a text file that is laid out like this:
Text Text
Text Text Text Text Text
Text Num Num Num Num
Text Num Num Num Num
Text Num Num Num Num
My code is:
def readData():
myList =[]
myFile = open("football.txt", "r")
for lines in myFile:
league = lines.split()
myList.append(league)
return myList
How can I skip the first two row so I can store everything else into my list?
Upvotes: 1
Views: 21373
Reputation: 1718
You can also use the readlines()
for this purpose
myFile = open("football.txt", "r")
lines = myFile.readlines()[2:] #To skip two lines.
#rest of the code
You could also specify the number of lines you want to skip.
Upvotes: 1