Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45852
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Subject | Re: suppress newlines in my script |
| Date | 2013-05-23 19:11 -0400 |
| Organization | > Bestiaria Support Staff < |
| References | <52c74908-8bac-498e-9549-5b9500b152f1@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2043.1369350733.3114.python-list@python.org> (permalink) |
On Thu, 23 May 2013 13:49:02 -0700 (PDT), sloan949@gmail.com declaimed
the following in gmane.comp.python.general:
> 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()
>
You state it is a comma separated file... Python has, for years, a
module just for handling CSV (or tab separated, or even others if you
define the "dialect").
> BU = 'Company,,,,,,,,,,,,,,'
> PPP = 'Pre-Prod,,,,,,,,Prod,,,,,,'
> C1 = ',,,,,,,,,,,,,,'
> Title = 'Site,Environment,'
> NET1 = lines[4]
What is "lines[4]" supposed to look like?
<snip>
>
>
> for count in range(64, 127):
> print NET1.format(count)
And what do you expect this to produce? NET1 is being used as a
template into which you are placing (if it has a placeholder) integers
in the range 64..126
An example of the input file, and an example of what you expect to
produce with it, would be useful.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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