0

I have a ".txt" file where I have a string say "Function supported" and "Function Description" I have multiple lines between these two string starting with say "-". How to get each line and apply some changes on it? To get the substring I can do :

substr = list[list.find("Functionality supported")+1:list.find("Functionality     Description")]
print ("Apply h1 to substr\n")

Will this helpful and if so how to apply only to text in each line not to "-". Also this "substr" has all those lines, should I apply split on substr , if so how?

thanks in advance -Pankaj

1 Answer 1

1

You can split the substring into separate strings:

substrings = substr.split('\n-')

Then apply the changes to each of the substrings, and finally join them back:

result = '\n-'.join(substrings)
Sign up to request clarification or add additional context in comments.

2 Comments

Sorry but this is not what I want as changes are to change the ".txt" to ".html" file with different formatting style , I mean the headers and change some headers to links and so on.
@user1389673: It is what you asked for. If you want something completely different than what you asked for, I suggest you start a new question, and ask what you want this time. Apparently you want to extract some data from a txt file and generate an HTML file from that. It's a very different question than the one you posed, where you want to "apply some changes" to some lines in a txt file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.