Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103534 > unrolled thread
| Started by | Ganesh Pal <ganesh1pal@gmail.com> |
|---|---|
| First post | 2016-02-26 16:37 +0530 |
| Last post | 2016-02-27 22:08 +0530 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
How to remove the line numbers from the file in python Ganesh Pal <ganesh1pal@gmail.com> - 2016-02-26 16:37 +0530
Re: How to remove the line numbers from the file in python "Peter Heitzer" <peter.heitzer@rz.uni-regensburg.de> - 2016-02-26 11:31 +0000
Re: How to remove the line numbers from the file in python Ganesh Pal <ganesh1pal@gmail.com> - 2016-02-27 22:08 +0530
| From | Ganesh Pal <ganesh1pal@gmail.com> |
|---|---|
| Date | 2016-02-26 16:37 +0530 |
| Subject | How to remove the line numbers from the file in python |
| Message-ID | <mailman.145.1456484839.20994.python-list@python.org> |
what would be the easiest way to remove the lines in the leading
numbers 1.e 1 ,2,.... 19 from this file using python ?
1 import os
2 Suite = "Test Mail"
3
4 def sendMail(x):
5 text = x
6 sendmail_location = "/home/prasad/onefs/share/sendmail" #
sendmail location
7 p = os.popen("%s -t" % sendmail_location, "w")
8 p.write("From: %s\n" % "ganesh.pal@gmail.com")
9 p.write("To: %s\n" % "ganesh.pal@gmail.com")
10 #p.write("To: %s\n" % "umamaheshwar.b@gmail.com")
11 p.write("Subject: Suite : %s \n" % (Suite))
12 p.write("\n") # blank line separating headers from body
13 p.write("%s" %text)
14 status = p.close()
15
16 if status != 0:
17 print "Sendmail exit status", status
18
19 sendMail("Test Mail")
Regards,
Ganesh
[toc] | [next] | [standalone]
| From | "Peter Heitzer" <peter.heitzer@rz.uni-regensburg.de> |
|---|---|
| Date | 2016-02-26 11:31 +0000 |
| Message-ID | <djarckFeuqsU1@mid.individual.net> |
| In reply to | #103534 |
Ganesh Pal <ganesh1pal@gmail.com> wrote:
>what would be the easiest way to remove the lines in the leading
>numbers 1.e 1 ,2,.... 19 from this file using python ?
import sys,re
for line in sys.stdin:
print re.sub('^\d+','',line).rstrip()
[toc] | [prev] | [next] | [standalone]
| From | Ganesh Pal <ganesh1pal@gmail.com> |
|---|---|
| Date | 2016-02-27 22:08 +0530 |
| Message-ID | <mailman.180.1456591123.20994.python-list@python.org> |
| In reply to | #103536 |
Thanks it works fine :)
On Fri, Feb 26, 2016 at 5:01 PM, Peter Heitzer
<peter.heitzer@rz.uni-regensburg.de> wrote:
> Ganesh Pal <ganesh1pal@gmail.com> wrote:
>>what would be the easiest way to remove the lines in the leading
>>numbers 1.e 1 ,2,.... 19 from this file using python ?
> import sys,re
> for line in sys.stdin:
> print re.sub('^\d+','',line).rstrip()
>
> --
> https://mail.python.org/mailman/listinfo/python-list
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web