On Sun, 09 Nov 2014 11:58:49 -0800, Syed Khalid wrote:
> 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.
Sounds like you need sed, not python.
--
Denis McMahon, denismfmcma...@gma
>-Original Message-
>From: Python-list [mailto:python-list-
>bounces+crk=godblessthe...@python.org] On Behalf Of Syed Khalid
>Sent: Sunday, November 09, 2014 1:08 PM
>To: python-list@python.org
>Subject: Re: Python script that does batch find and replace in txt files
On Sun, 09 Nov 2014 17:49:29 -0800, Syed Khalid wrote:
> Albert,
>
> Code is not removing empty lines containing blank characters and not
> removing leading and trailing spaces present in each line.
>
>
>
>
> import glob, codecs, re, os
>
> regex = re.compile(r"Age: |Sex: |House No: ") # e
Albert,
Code is not removing empty lines containing blank characters and not removing
leading and trailing spaces present in each line.
import glob, codecs, re, os
regex = re.compile(r"Age: |Sex: |House No: ") # etc etc
for txt in glob.glob("D:/Python/source/*.txt"):
with codecs.o
On Sun, Nov 9, 2014 10:51 PM CET Syed Khalid wrote:
>Albert,
>
>Thanks a million for script,
>
>It worked fine after I closed the bracket.
>
>
>import glob, codecs, re, os
>
>regex = re.compile(r"Age: |Sex: |House No: ") # etc etc
>
>for txt in glob.glob("D:/Python/s
Albert,
Thanks a million for script,
It worked fine after I closed the bracket.
import glob, codecs, re, os
regex = re.compile(r"Age: |Sex: |House No: ") # etc etc
for txt in glob.glob("D:/Python/source/*.txt"):
with codecs.open(txt, encoding="utf-8") as f:
oldlines = f.readlines
On 2014-11-09 21:20, Syed Khalid wrote:
Code after adding path of .txt files :
import glob, codecs, re, os
regex = re.compile(r"Age: |Sex: |House No: ") # etc etc
for txt in glob.glob("D:/Python/source/*.txt"):
with codecs.open(txt, encoding="utf-8") as f:
oldlines = f.readlines
Code after adding path of .txt files :
import glob, codecs, re, os
regex = re.compile(r"Age: |Sex: |House No: ") # etc etc
for txt in glob.glob("D:/Python/source/*.txt"):
with codecs.open(txt, encoding="utf-8") as f:
oldlines = f.readlines()
for i, line in enumerate(oldlines):
My Script,
I have added
import glob, codecs, re, os
regex = re.compile(r"Age: |Sex: |House No: ") # etc etc
Script I executed in EditRocket :
for txt in glob.glob("/D:/Python/source/*.txt"):
with codecs.open(txt, encoding="utf-8") as f:
oldlines = f.readlines()
for i, line
Hi Albert,
Thank you for script.
I am getting the below error :
File "EamClean.log", line 12
with codecs.open(txt + "_out.txt", "wb", encoding="utf-8") as w:
^
SyntaxError: invalid syntax
Kindly do the needful.
On Mon, Nov 10, 2014 at 1:53 AM, Albert-Jan Roskam wrote:
>
>
>
>
>
- Original Message -
> From: Syed Khalid
> To: python-list@python.org
> Cc:
> Sent: Sunday, November 9, 2014 8:58 PM
> Subject: Python script that does batch find and replace in txt files
>
> Python script that does batch find and replace in txt files Need a python
> script
> that
On 09/11/2014 19:58, Syed Khalid wrote:
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 star
12 matches
Mail list logo