Keeping it simple, [omitting scale and parallelism], I'm trying to read a text file. On that text file, there are entries which run over more than one line (other software has character entry limits). An example is below
#Iterating through the file
with open(fileName, 'r') as file:
#Examining each line
for line in file:
#If the first three characters meet a condition
if line[:3] == "aa ":
#If the last character is not a condition
if line.rstrip()[-1:] != "'":
#Then this entry effectively runs onto *at least* the next line
#Store the current line in a buffer for reuse
temp = line
#Here is my issue, I don't want to use a 'for line in file' again, as that would require me to write multiple "for" & "if" loops to consider the possibility of entries running over several lines
[Pseudocode]
while line.rstrip()[-1:] in file != "'":
#Concatenate the entries to date
temp = temp + line
#entry has completed
list.append(temp)
else
#Is a single line entry
list.append(line)
But, its obviously not liking the while loop. I've had a look around and not come across anything. Anyone any ideas? Thanks.
line = next(file).