Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #103534

How to remove the line numbers from the file in python

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Ganesh Pal <ganesh1pal@gmail.com>
Newsgroups comp.lang.python
Subject How to remove the line numbers from the file in python
Date Fri, 26 Feb 2016 16:37:11 +0530
Lines 27
Message-ID <mailman.145.1456484839.20994.python-list@python.org> (permalink)
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de Inp73sedsyAXRCyB3KlknQrRb464WEiuP/rk3Cke4nNg==
Return-Path <ganesh1pal@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'exit': 0.07; 'subject:file': 0.07; 'subject:How': 0.09; '"w")': 0.09; '%s\\n"': 0.09; 'separating': 0.09; 'python': 0.10; 'def': 0.13; 'subject:python': 0.14; 'headers': 0.15; '"test': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'status",': 0.16; 'subject:remove': 0.16; 'skip:" 30': 0.20; 'to:name:python- list@python.org': 0.20; 'import': 0.24; 'skip:# 10': 0.27; 'message-id:@mail.gmail.com': 0.27; 'subject:numbers': 0.29; 'print': 0.30; 'file': 0.34; 'received:google.com': 0.35; 'text': 0.35; 'easiest': 0.35; 'lines': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'received:209': 0.38; 'subject:from': 0.39; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'leading': 0.61; 'body': 0.61; 'mail"': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=vyk9hrpBpMP+H34JI8MAsEZQ+aWtMNTc0sVST+Tdl34=; b=vYdxh26ljNFEgsJyGq1cikWywymu2UN7FMoGIYYG6SmQzC3+CJPmX6lTaQy6U/G/RT MIcmbKHHMBI4gWhJFW2XvE/HDA9qL1PTJD4wLBv2WuOHuEgOgzfzz8LdHRWlaQro6dgP dZt8Sl3aYd5MijZDSSRyRCIaYYsdmUAt1Er+qtxrVIkD7mkj5FMSoxz5RI0cbaxqfZBI 0LiwNfujlj+rsidQrEgePqKN/LPyVcw59g+DbtzG6P31Bx8/sz31S/JMZ5EOhCNZ9Coc tSVk9dIL7zvYH6si+BpmC1y45D34oEZ+OLQ+7vy40mIE3agIZRzznysrP7UzfSowgrCZ tDrg==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=vyk9hrpBpMP+H34JI8MAsEZQ+aWtMNTc0sVST+Tdl34=; b=HwIGVr8+WEoMv3S/sH/LZ+kf7LUqoCOPlUhmU6l6IXk5gXjbX0k8UXGGdiiNCOMLYP BT6YrOBqljw3DO/3S91SEsG/Bz2DfDkfX5A2m20YP2Vv6FC5v8jgpnGxM22bgAlWmMM/ q3XsjAMr3bd3sii+tdSlUk9nDXl02bS6gVZ/hyDVUZHRxrtD7bXLpBfuNpYjMeoyFlK3 UT07r0mGL9la2uhIR7X4bLsG5KyqXPK2SL00HUqKu5Bc5iRh/4Xonxyvve2sGEo2U7Km p7G+OUvcOBci+larhQU6Q2ZPSynLl6U21hOnfbZvEnC5UxJe4Y3XMmRm4/T783NgsP30 0xSQ==
X-Gm-Message-State AD7BkJLRS/8sFUnaaA9Wfp3BhhEYkQB0ndL7d7cU78hxjYfDvQWg+HkU82TYRb8+RjVdRcejpyCvT6wc+5IRyg==
X-Received by 10.112.167.37 with SMTP id zl5mr415394lbb.60.1456484831878; Fri, 26 Feb 2016 03:07:11 -0800 (PST)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21rc2
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:103534

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

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

csiph-web