My input file test.sas file looks like below:
My
Name is Joe
How are you?;
/* Comment 1 */
/*Comment 2
blah blah
blah blah blah
blah blah blah blah;*/
/* Comment 3 */
I am great
When I use the following code I get the result that is right after the code:
writing = True
with open('test.sas', 'r') as file:
with open('output.sas','w') as out:
for line in file:
if writing:
if '/*' in line:
writing = False
else:
out.write(line)
elif '*/' in line:
writing = True
the result:
My
Name is Joe
How are you?;
But I would like to get the following result:
My
Name is Joe
How are you?;
I am great
I can't figure out what I am doing wrong. Basically I want to remove the text within the comment block and write the rest to the output file.
/*OR*/on a line because of yourelif(not lines with both). Change that to anif