Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80437
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2014-11-09 11:58 -0800 |
| Message-ID | <e9ee1f6f-9397-4dc5-a357-381ebc9b6e57@googlegroups.com> (permalink) |
| Subject | Python script that does batch find and replace in txt files |
| From | Syed Khalid <khalidness@gmail.com> |
Python script that does batch find and replace in txt files Need a python script that opens all .txt files in a folder find replace/delete text and save files. I have text files and I need to perform below steps for each file. Step 1: Put cursor at start of file and Search for "Contact's Name:". Delete all the rows before it. Step 2: Put cursor at end of file, Search for "Contact's Name:" select option UP. Step 3: Search for "Photo of the" Replace with blanks Step 4: Search for "Contact is" Replace with blanks Step 5: Search for "Contact's Name:" Replace with blanks Step 6: Search for "Age:" Replace with blanks Step 7: Search for "Sex:" Replace with blanks Step 8: Search for "House No:" Replace with blanks Step 9: Search for "available" Replace with blanks Step 10: Remove Empty Lines Containing Blank Characters from file Step 11: Trim Leading Space for each line Step 12: Trim Trailing Space after each line Step 13: Search for - (hyphen) Replace with _ (underscore) Step 14: Save file. Currently I have recorded a macro in Notepad++. I open each file, run macro and save file. As there are many files I was looking for a program to automate the process. I posted the same query in Notepad++ forum. I got a reply that it can be done by using Python script. Kindly do the needful. Thank you. khalidness
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Python script that does batch find and replace in txt files Syed Khalid <khalidness@gmail.com> - 2014-11-09 11:58 -0800
Re: Python script that does batch find and replace in txt files Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-09 20:17 +0000
Re: Python script that does batch find and replace in txt files Albert-Jan Roskam <fomcl@yahoo.com> - 2014-11-09 20:23 +0000
Re: Python script that does batch find and replace in txt files Syed Khalid <khalidness@gmail.com> - 2014-11-10 02:22 +0530
Re: Python script that does batch find and replace in txt files Syed Khalid <khalidness@gmail.com> - 2014-11-09 13:08 -0800
RE: Python script that does batch find and replace in txt files "Clayton Kirkwood" <crk@godblessthe.us> - 2014-11-09 15:03 -0800
Re: Python script that does batch find and replace in txt files Syed Khalid <khalidness@gmail.com> - 2014-11-10 02:50 +0530
Re: Python script that does batch find and replace in txt files MRAB <python@mrabarnett.plus.com> - 2014-11-09 21:44 +0000
Re: Python script that does batch find and replace in txt files Syed Khalid <khalidness@gmail.com> - 2014-11-10 03:21 +0530
Re: Python script that does batch find and replace in txt files Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-11 20:04 +0000
csiph-web