This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hello everyone. I'm a rank beginner to python coding and I'm totally flummoxed with my issue. All my attempts to figure out a solution to my code have been dead ends so reddit is my last resort. I have a code that goes into a folder full of text files and edits all of them. The target text phrase (the one I want to edit) from text file to text file is not consistent. I am using a loop in attempting to change the text to this consistent result:
"FIRST INSTANCE,"
Throughout the texts the examples I am trying to replace look like this:
"FIRSTINSTANCE\n" - with no space "FIRST INSTANCE\n" - with one space "FIRST INSTANCE\n" - with two or more spaces
The first two examples change to exactly what I want them to change to. However, for some reason my target string (target = "FIRST INSTANCE\n") doesn't seem to find the text phrases with two spaces, so all the text files in the folder whose target phrase has two spaces or more remain unchanged. Why is this happening? What am I doing wrong? There are big gaps in my Python knowledge base as I am learning as I'm going along so please forgive me if there is a simple syntax solution to this. Thanks for taking the time to read this.
Subreddit
Post Details
- Posted
- 1 year ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/pythonquest...