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


Groups > comp.lang.python > #41778

Re: Separate Rows in reader

Newsgroups comp.lang.python
Date 2013-03-24 01:11 -0700
References <fdcdb6d8-c63a-4909-8b56-13204a0d474c@googlegroups.com> <mailman.3662.1364104023.2939.python-list@python.org>
Subject Re: Separate Rows in reader
From Jiewei Huang <jiewei24@gmail.com>
Message-ID <mailman.3665.1364127021.2939.python-list@python.org> (permalink)

Show all headers | View raw


On Sunday, March 24, 2013 3:46:49 PM UTC+10, Dave Angel wrote:
> On 03/24/2013 01:20 AM, Jiewei Huang wrote:
> 
> > Hi all,
> 
> >
> 
> > Currently create a simple text-based database of information about people
> 
> >
> 
> >
> 
> > I have a csv file which consist of 3 rows , row 1 2 and 3 is as such:
> 
> > Name	 Address	Telephone	Birthday
> 
> > John Konon	Ministry of Moon Walks	4567882	27-Feb
> 
> > Stacy Kisha	Ministry of Man Power	1234567	17-Jan
> 
> >
> 
> >
> 
> > My codes are :
> 
> > import csv
> 
> > original = file('friends.csv', 'rU')
> 
> > reader = csv.reader(original)
> 
> >
> 
> > for row in reader:
> 
> >
> 
> >      print row
> 
> >
> 
> >
> 
> > and the output is :
> 
> > ['Name', ' Address', 'Telephone', 'Birthday']
> 
> > ['John Konon', 'Ministry of Moon Walks', '4567882', '27-Feb']
> 
> > ['Stacy Kisha', 'Ministry of Man Power', '1234567', '17-Jan']
> 
> >
> 
> > But i wanted to make it
> 
> >
> 
> > [('John Cleese', 'Ministry of Silly Walks', '5555421', '27-Feb'),
> 
> > ( 'Stacy Kisha', 'Ministry of Man Power', '1234567', 17-Jan')]
> 
> >
> 
> > can someone show me guidance to this issue
> 
> >
> 
> > Thanks all
> 
> >
> 
> 
> 
> There are at least 3 differences to the printouts.  Which difference are 
> 
> you concerned with?
> 
> 
> 
> 1) Moon --> Silly
> 
> 2) square and round brackets in slightly different places
> 
> 3) row 0 suppressed
> 
> 
> 
> Explain which one, or specify a fourth, and also what you have tried to 
> 
> address the question.
> 
> 
> 
> 
> 
> -- 
> 
> DaveA


Sorry my typo in the output here is the correct output that i need :

[('John Konon', 'Ministry of moon Walks', '4567882', '27-Feb'), 
( 'Stacy Kisha', 'Ministry of Man Power', '1234567', 17-Jan')] 

the difference is that i need a [(row two), (row three), (row fouth)] . I do not want to display row one which is ['Name', ' Address', 'Telephone', 'Birthday'] 

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


Thread

Separate Rows in reader Jiewei Huang <jiewei24@gmail.com> - 2013-03-23 22:20 -0700
  Re: Separate Rows in reader Dave Angel <davea@davea.name> - 2013-03-24 01:46 -0400
    Re: Separate Rows in reader rusi <rustompmody@gmail.com> - 2013-03-24 00:34 -0700
      Re: Separate Rows in reader Jiewei Huang <jiewei24@gmail.com> - 2013-03-24 01:18 -0700
    Re: Separate Rows in reader Jiewei Huang <jiewei24@gmail.com> - 2013-03-24 01:11 -0700
      Re: Separate Rows in reader Dave Angel <davea@davea.name> - 2013-03-24 09:03 -0400
      Re: Separate Rows in reader Tim Chase <python.list@tim.thechases.com> - 2013-03-24 08:49 -0500
        Re: Separate Rows in reader rusi <rustompmody@gmail.com> - 2013-03-24 08:57 -0700
          Re: Separate Rows in reader Tim Chase <python.list@tim.thechases.com> - 2013-03-24 13:28 -0500
            Re: Separate Rows in reader rusi <rustompmody@gmail.com> - 2013-03-24 19:08 -0700
    Re: Separate Rows in reader Jiewei Huang <jiewei24@gmail.com> - 2013-03-24 01:11 -0700
  Re: Separate Rows in reader ypsun <winter0128@gmail.com> - 2013-03-24 03:58 -0700
  Re: Separate Rows in reader ypsun <winter0128@gmail.com> - 2013-03-24 04:10 -0700
    Re: Separate Rows in reader Jiewei Huang <jiewei24@gmail.com> - 2013-03-24 23:52 -0700
      Re: Separate Rows in reader rusi <rustompmody@gmail.com> - 2013-03-25 06:51 -0700
        Re: Separate Rows in reader Jiewei Huang <jiewei24@gmail.com> - 2013-03-25 18:05 -0700
          Re: Separate Rows in reader Dave Angel <davea@davea.name> - 2013-03-25 21:40 -0400
            Re: Separate Rows in reader Jiewei Huang <jiewei24@gmail.com> - 2013-03-25 20:33 -0700
              Re: Separate Rows in reader MRAB <python@mrabarnett.plus.com> - 2013-03-26 03:48 +0000
                Re: Separate Rows in reader Jiewei Huang <jiewei24@gmail.com> - 2013-03-26 00:24 -0700
                Re: Separate Rows in reader Jiewei Huang <jiewei24@gmail.com> - 2013-03-26 00:24 -0700
                Re: Separate Rows in reader Jiewei Huang <jiewei24@gmail.com> - 2013-03-27 02:35 -0700
                Re: Separate Rows in reader rusi <rustompmody@gmail.com> - 2013-03-27 04:18 -0700
                Re: Separate Rows in reader Jiewei Huang <jiewei24@gmail.com> - 2013-03-27 15:12 -0700
                Re: Separate Rows in reader Jiewei Huang <jiewei24@gmail.com> - 2013-03-27 15:26 -0700
                Re: Separate Rows in reader rusi <rustompmody@gmail.com> - 2013-03-27 18:24 -0700
                Re: Separate Rows in reader Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-28 01:32 +0000
                Re: Separate Rows in reader Jiewei Huang <jiewei24@gmail.com> - 2013-03-27 02:35 -0700
                Re: Separate Rows in reader Tim Roberts <timr@probo.com> - 2013-03-28 21:28 -0700
            Re: Separate Rows in reader Jiewei Huang <jiewei24@gmail.com> - 2013-03-25 20:33 -0700
  Re: Separate Rows in reader Jiewei Huang <jiewei24@gmail.com> - 2013-03-24 18:15 -0700

csiph-web