Python Forum
printing set of lines between patterns - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: printing set of lines between patterns (/thread-1202.html)



printing set of lines between patterns - pybegin - Dec-13-2016

I have a requirement were in i need to print the lines between 2 patterns into files 
The text in the below format is available in a file. The requirement is to create a new file for each "StartPattern" and write the lines after it into the file till the "EndPattern" is reached. The StartPattern names change but the EndPattern is a constant string.  I'm new to python so unable to get a complete program to do it

<StartPattern1>
line1
line2
line3
line4
<EndPattern>

<StartPattern2>
line1
line2
line3
<EndPattern>

....
....
....

Example Output
============

1. StartPattern1.txt
2. StartPattern2.txt


RE: printing set of lines between patterns - Mekire - Dec-13-2016

(Dec-13-2016, 10:22 AM)pybegin Wrote:  I'm new to python so unable to get a complete program to do it
We will still need to see an attempt and hear what exact problem you are facing before we will be able (willing) to help you.


RE: printing set of lines between patterns - nilamo - Dec-13-2016

I, personally, come here to help people learn python. Not to write code. I have a day job (...and projects I work on on the weekends/nights) for that. Give it a try, and a lot of us will gladly help you figure out what you can't. But we won't start/finish it for you.