file1
cat
dog
fish
file2
This is a bunch of lines
<!-- INSERT ANIMALS HERE -->
horse
cheetah
post results
file2
This is a bunch of lines
<!-- INSERT ANIMALS HERE -->
cat
dog
fish
horse
cheetah
code so far
import re
regex = re.compile(r"<[^*]-- INSERT ANIMALS HERE -->")
line_found = False
with open('file1.xml') as file1:
for line in file1:
if re.match(regex, line):
line_found = True
break
with open('../file2.xml', 'a') as file2:
if line_found:
for line in file1:
file2.write(line)
does not appear to be working at all