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


Groups > comp.lang.python > #45843

suppress newlines in my script

Newsgroups comp.lang.python
Date 2013-05-23 13:49 -0700
Message-ID <52c74908-8bac-498e-9549-5b9500b152f1@googlegroups.com> (permalink)
Subject suppress newlines in my script
From sloan949@gmail.com

Show all headers | View raw


I am importing lines from an external csv file and when I iterate through the lines and increment, new lines are introduced.
How would I cut out the newlines.  I have attempted several pythonic strip() and rstrip() how can i implent this?


import sys, os

f=open('europe_csv')
lines=f.readlines()

BU = 'Company,,,,,,,,,,,,,,'
PPP = 'Pre-Prod,,,,,,,,Prod,,,,,,'
C1 = ',,,,,,,,,,,,,,'
Title = 'Site,Environment,'
NET1 = lines[4]
GW1 = lines[5]
M1 = lines[6]
PS1 = lines[7]
PE1 = lines[8]
C2 = ',,,,,,,,,,,,,,'
NET2 = lines[10]
GW2 = lines[11]
M2 = lines[12]
PS2 = lines[13]
PE2  = lines[14]



for count in range(64, 127):
 print NET1.format(count)
 print GW1.format(count)
 print M1
 print PS1.format(count)
 print PE1.format(count)
 print C2
 print NET2.format(count)
 print GW2.format(count)
 print M2
 print PS2.format(count)
 print PE2.format(count)

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


Thread

suppress newlines in my script sloan949@gmail.com - 2013-05-23 13:49 -0700
  Re: suppress newlines in my script Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-05-23 19:11 -0400
  Re: suppress newlines in my script sloan949@gmail.com - 2013-05-24 06:59 -0700
    Re: suppress newlines in my script Dave Angel <davea@davea.name> - 2013-05-24 15:24 -0400
    Re: suppress newlines in my script Jason Friedman <jsf80238@gmail.com> - 2013-05-24 21:49 -0600
    Re: suppress newlines in my script Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-05-25 13:33 -0400

csiph-web