I have written a script that reads data from two different files and proceeds accordingly. However, when I wrote the script I was under the impression that the first file from which I am reading only has two lines, sadly this has since changed.
My code extracts the first two lines and passes the data to another function, which then proceeds to do the calculation by passing through multiple other functions.
Right now I am doing something like this:
try:
file = open(myfile, 'r')
for line in file:
if line[0] != '|':
name = line.strip('\n')
else:
data = line.strip('|\n')
The file, in general, looks like this:
Samantha
|j&8ju820kahu9|
Now, sadly, I can have a file that can have multiple lines, as follows:
Andy
|o81kujd0-la88js|
Mathew
|a992kma82nf-x01j4|
Andrew
|01ks83nnz;a82jlad|
Is there a way where I can extract two lines at a time from a file? Process them and then proceed to extract two more? So grab the first two lines, give them to name + data, which pass it to my function, eventually printing what is required, and then get the new two lines and so forth.
Please advice.