Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.064 X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'output': 0.05; 'problem?': 0.07; 'method:': 0.09; 'bracket': 0.16; 'buggy': 0.16; 'commas,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'mylist': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject:reader': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'split': 0.19; '>>>': 0.22; 'input': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'software.': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; "i'm": 0.30; 'code': 0.31; '25,': 0.31; 'quotes': 0.31; 'url:python': 0.33; 'monday,': 0.33; 'problem': 0.35; 'advice': 0.35; 'received:84': 0.35; 'there': 0.35; 'version': 0.36; 'method': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'list.': 0.37; 'starting': 0.37; 'implement': 0.38; 'skip:o 20': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'pm,': 0.38; 'previous': 0.38; 'embedded': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'remove': 0.60; 'dave': 0.60; 'skip:z 20': 0.60; 'march': 0.61; 'show': 0.63; 'header :Reply-To:1': 0.67; '26,': 0.68; 'reply-to:no real name:2**0': 0.71; 'power': 0.76; "it'd": 0.84; 'reply-to:addr:python.org': 0.84; 'specs.': 0.84; 'angel': 0.91; 'ministry': 0.91; 'rusi': 0.91; '2013': 0.98 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.0 cv=HO4d4PRv c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=B68SgI_Jlq8A:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=IoN6p0HFfOoA:10 a=Y447_5pCwkvdB0jZSXoA:9 a=wPNLvfGTeEIA:10 a=6mSPqtV_LXQA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 X-AUTH: mrabarnett:2500 Date: Tue, 26 Mar 2013 03:48:10 +0000 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Separate Rows in reader References: <4e1e93e5-14bd-4408-9c92-3c340e558deb@googlegroups.com> <3054bd15-f3d3-4568-aea2-567dd6d762de@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364269874 news.xs4all.nl 6865 [2001:888:2000:d::a6]:33578 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41850 On 26/03/2013 03:33, Jiewei Huang wrote: > On Tuesday, March 26, 2013 11:40:51 AM UTC+10, Dave Angel wrote: >> On 03/25/2013 09:05 PM, Jiewei Huang wrote: >>> On Monday, March 25, 2013 11:51:51 PM UTC+10, rusi wrote: >> >> If you insist on using GoogleGroups, then make sure you keep your quotes >> small. I'm about to stop reading messages that are double-spaced by >> buggy software. >> >> >>> >> >> Have you tried the split (and perhaps strip) methods from >> >> >> >> http://docs.python.org/2/library/stdtypes.html#string-methods >> >> >> >> ? >> >> You got lots of specific advice from your previous thread. So which >> version did you end up using? It'd make a good starting place for this >> "problem." >> >> > can show me one line of how to implement it base on my problem? >> > >> >> As long as the input data is constrained not to have any embedded >> commas, just use: >> >> mylist = line.split(",") >> >> instead of print, send your output to a list. Then for each line in the >> list, fix the bracket problem to your strange specs. >> >> outline = outline.replace("[", "(") > > Hi Dave thanks for the tips, > > I manage to code this: > f = open('Book1.csv', 'rU') > for row in f: > print zip([row for (row) in f]) > > however my output is > [('John Konon Ministry of Moon Walks 4567882 27-Feb\n',), ('Stacy Kisha Ministry of Man Power 1234567 17-Jan\n',)] > > is there any method to remove the \n ? > Use the .rstrip method: print zip(row.rstrip('\n') for row in f)