On Feb 19, 12:24 am, Steve Holden wrote:
> Rudi Goldman wrote:
> > Hi,
> > Go easy on me as I am a new to Python and am trying to solve a practical
> > problem that is driving me bananas.
> > Basically I have 2 text files, a source and a target. I want to be able
> > to delete all of the lines in
Rudi Goldman wrote:
> Hi,
> Go easy on me as I am a new to Python and am trying to solve a practical
> problem that is driving me bananas.
> Basically I have 2 text files, a source and a target. I want to be able
> to delete all of the lines in the target file which contain text from
> any line in
Hi,
Go easy on me as I am a new to Python and am trying to solve a practical
problem that is driving me bananas.
Basically I have 2 text files, a source and a target. I want to be able to
delete all of the lines in the target file which contain text from any line
in the source file.
i.e.
Source:
antar2 wrote:
> I am new in python and I have the following problem:
>
> Suppose I have a list with words of which I want to remove each time
> the words in the lines below item1 and above item2:
> f = re.compile("item\[1\]\:")
> g = re.compile("item\[2\]\:")
> for i, line in enumerate(list1):
>
I am new in python and I have the following problem:
Suppose I have a list with words of which I want to remove each time
the words in the lines below item1 and above item2:
item1
a
b
item2
c
d
item3
e
f
item4
g
h
item1
i
j
item2
k
l
item3
m
n
item4
o
p
I did not find out how to do this:
Part o
On Jan 7, 1:21 am, Francesco Pietra <[EMAIL PROTECTED]> wrote:
> Please, how to adapt the following script (to delete blank lines) to delete
> lines containing a specific word, or words?
>
> f=open("output.pdb", "r")
> for line in f:
>
Francesco Pietra wrote:
>
> Please, how to adapt the following script (to delete blank lines) to
> delete
> lines containing a specific word, or words?
>
> f=open("output.pdb", "r")
> for line in f:
> line=line.rstrip()
> if line:
As I said I am no expert in OS and commands, except on what concerns mechanical
statistical and quantum mechanical calculations. Therefore, better for me (and
for all guys here) if I stop on this matter. My reply is only to say that I did
the job with:
f=open("prod1-3_no_wat_pop.pdb", "r")
for lin
; >
> >> On Sun, 06 Jan 2008 09:21:33 -0800, Francesco Pietra wrote:
> >>
> >> > Please, how to adapt the following script (to delete blank lines) to
> >> > delete lines containing a specific word, or words?
> >>
> >> That's tricky,
On Mon, 07 Jan 2008 00:42:01 +, Grant Edwards wrote:
>> If you want to delete them, you still have to do the rest of the job
>> yourself.
>
> Nonsense.
>
> How is this not doing what the OP asks?
>
>grep -v pattern infile >outfile; mv outfile infile
It isn't deleting lines. As abstract
On Mon, 07 Jan 2008 00:33:36 +0100, Bjoern Schliessmann wrote:
> Steven D'Aprano wrote:
>
>> grep doesn't delete lines. grep matches lines. If you want to delete
>> them, you still have to do the rest of the job yourself.
>
> In which way does "grep -v my
gt;>
>>> On Sun, 06 Jan 2008 09:21:33 -0800, Francesco Pietra wrote:
>>>
>>> > Please, how to adapt the following script (to delete blank lines) to
>>> > delete lines containing a specific word, or words?
>>>
>>> That's tricky,
On Jan 6, 3:33 pm, Bjoern Schliessmann wrote:
> Steven D'Aprano wrote:
> > grep doesn't delete lines. grep matches lines. If you want to
> > delete them, you still have to do the rest of the job yourself.
>
> In which way does "grep -v mypattern myfile >
Steven D'Aprano wrote:
> grep doesn't delete lines. grep matches lines. If you want to
> delete them, you still have to do the rest of the job yourself.
In which way does "grep -v mypattern myfile > myfile" not delete the
lines matching mypattern?
Regards,
Björn
; Please, how to adapt the following script (to delete blank lines) to
>> > delete lines containing a specific word, or words?
>>
>> That's tricky, because deleting lines from a file isn't a simple
>> operation. No operating system I know of (Windows, Linux,
On Sunday 06 January 2008 21:25 Francesco Pietra wrote:
>> yes lines starting with a "#" are comments in python but that shouldn't
>> be of concern for your input data. I don't quite get what you want
>> here...
>
> Leaving the lines commented out would permit to resume them or at least
> remeber
Steven:
Thanks. See below please (of very marginal interest)
--- Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> On Sun, 06 Jan 2008 09:21:33 -0800, Francesco Pietra wrote:
>
> > Please, how to adapt the following script (to delete blank lines) to
> > delete lines c
On Sun, 06 Jan 2008 09:21:33 -0800, Francesco Pietra wrote:
> Please, how to adapt the following script (to delete blank lines) to
> delete lines containing a specific word, or words?
That's tricky, because deleting lines from a file isn't a simple
operation. No operating
--- Martin Marcher <[EMAIL PROTECTED]> wrote:
> On Sunday 06 January 2008 18:21 Francesco Pietra wrote:
>
> > Please, how to adapt the following script (to delete blank lines) to
> > delete lines containing a specific word, or words?
> >
> > f=open(
On Sunday 06 January 2008 18:21 Francesco Pietra wrote:
> Please, how to adapt the following script (to delete blank lines) to
> delete lines containing a specific word, or words?
>
> f=open("output.pdb", "r")
> for line in f:
> line=line.rstrip()
> if l
On 2008-01-06, Matt Nordhoff <[EMAIL PROTECTED]> wrote:
>> Please, how to adapt the following script (to delete blank lines) to delete
>> lines containing a specific word, or words?
> If you're on Linux, why not just use grep?
>
> $ grep -v theword output.pdb
A
)
> From: Francesco Pietra <[EMAIL PROTECTED]>
> Subject: Delete lines containing a specific word
> To: python-list@python.org
>
> Please, how to adapt the following script (to delete blank lines) to delete
> lines containing a specific word, or words?
>
> f=open("out
Francesco Pietra wrote:
> Please, how to adapt the following script (to delete blank lines) to delete
> lines containing a specific word, or words?
>
> f=open("output.pdb", "r")
> for line in f:
> line=line.rstrip()
> if line:
>
Please, how to adapt the following script (to delete blank lines) to delete
lines containing a specific word, or words?
f=open("output.pdb", "r")
for line in f:
line=line.rstrip()
if line:
print line
f.close()
If python in Linux accepts lines
24 matches
Mail list logo