Reading specific lines from a file (Python3)
Go to solution
Solved by Sauron,
2 minutes ago, lewdicrous said:There is a fixed number of lines for the header, body and footer. I'm trying to ignore the header and footer so that I can use the information from the body.
I have to open two text files that are more or less identical, take the information contained in both and add them to a third text file.. if that made any sense
then just change the second loop from this
while lines != "": print (lines.split()) lines = infile.readline()
to this
while count < 13:
print (lines.split())
lines = infile.readline()
count += 1
assuming the number of data lines is the same. If it isn't, well, as I said you should be checking for format.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now