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


Groups > comp.lang.python > #41767 > unrolled thread

Separate Rows in reader

Started byJiewei Huang <jiewei24@gmail.com>
First post2013-03-23 22:20 -0700
Last post2013-03-24 18:15 -0700
Articles 11 on this page of 31 — 8 participants

Back to article view | Back to comp.lang.python


Contents

  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

Page 2 of 2 — ← Prev page 1 [2]


#41863

FromJiewei Huang <jiewei24@gmail.com>
Date2013-03-26 00:24 -0700
Message-ID<mailman.3724.1364283327.2939.python-list@python.org>
In reply to#41850
On Tuesday, March 26, 2013 1:48:10 PM UTC+10, MRAB wrote:
> 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.
> 
> >>
> 
> >> >>> <SNIP>
> 
> >> >> 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)

thanks ! got it working!

[toc] | [prev] | [next] | [standalone]


#41998

FromJiewei Huang <jiewei24@gmail.com>
Date2013-03-27 02:35 -0700
Message-ID<45072d2b-e8ca-4888-92bc-2556c2c7568c@googlegroups.com>
In reply to#41850
On Tuesday, March 26, 2013 1:48:10 PM UTC+10, MRAB wrote:
> 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.
> 
> >>
> 
> >> >>> <SNIP>
> 
> >> >> 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)

Hi the output is:

[('John Cleese,Ministry of Silly Walks,5555421,27-Oct',), ('Stacy Kisha,Ministry of Man Power,1234567,17-Jan',)]

how to make it to

[CODE][('John Cleese', 'Ministry of Silly Walks' , '5555421', '27-Oct'), ('Stacy Kisha', 'Ministry of Man Power', '1234567,17-Jan')][/CODE]

i need ' ' in all the row and the , to be remove after the date

[toc] | [prev] | [next] | [standalone]


#42002

Fromrusi <rustompmody@gmail.com>
Date2013-03-27 04:18 -0700
Message-ID<3c1afe44-1eb4-4074-8f85-540c2a4bb842@oz4g2000pbc.googlegroups.com>
In reply to#41998
On Mar 27, 2:35 pm, Jiewei Huang <jiewe...@gmail.com> wrote:
> On Tuesday, March 26, 2013 1:48:10 PM UTC+10, MRAB wrote:
> > 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.
>
> > >> >>> <SNIP>
>
> > >> >> 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)
>
> Hi the output is:
>
> [('John Cleese,Ministry of Silly Walks,5555421,27-Oct',), ('Stacy Kisha,Ministry of Man Power,1234567,17-Jan',)]
>
> how to make it to
>
> [CODE][('John Cleese', 'Ministry of Silly Walks' , '5555421', '27-Oct'), ('Stacy Kisha', 'Ministry of Man Power', '1234567,17-Jan')][/CODE]
>
> i need ' ' in all the row and the , to be remove after the date

Everything you need for this has been answered by Tim, Dave, myself
(and others?).
If you are stuck, tell us where.
If something did not work, tell us what.

Dont you think if you are asking us to do your homework, you should
offer us a little fee?

[toc] | [prev] | [next] | [standalone]


#42044

FromJiewei Huang <jiewei24@gmail.com>
Date2013-03-27 15:12 -0700
Message-ID<4bc1553a-0689-4adc-b243-27c58865d639@googlegroups.com>
In reply to#42002
On Wednesday, March 27, 2013 9:18:28 PM UTC+10, rusi wrote:
> On Mar 27, 2:35 pm, Jiewei Huang <jiewe...@gmail.com> wrote:
> 
> > On Tuesday, March 26, 2013 1:48:10 PM UTC+10, MRAB wrote:
> 
> > > 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.
> 
> >
> 
> > > >> >>> <SNIP>
> 
> >
> 
> > > >> >> 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)
> 
> >
> 
> > Hi the output is:
> 
> >
> 
> > [('John Cleese,Ministry of Silly Walks,5555421,27-Oct',), ('Stacy Kisha,Ministry of Man Power,1234567,17-Jan',)]
> 
> >
> 
> > how to make it to
> 
> >
> 
> > [CODE][('John Cleese', 'Ministry of Silly Walks' , '5555421', '27-Oct'), ('Stacy Kisha', 'Ministry of Man Power', '1234567,17-Jan')][/CODE]
> 
> >
> 
> > i need ' ' in all the row and the , to be remove after the date
> 
> 
> 
> Everything you need for this has been answered by Tim, Dave, myself
> 
> (and others?).
> 
> If you are stuck, tell us where.
> 
> If something did not work, tell us what.
> 
> 
> 
> Dont you think if you are asking us to do your homework, you should
> 
> offer us a little fee?

Hi Rusi,

I'm struck and i did say what did not work and i did follow your guideline and i 
did come out with my own code which come out as a same result ( look at the #) not is not the one i need.

f = open('friends.csv', 'rU')
for row in f:
    #print zip([row.rstrip() for (row) in f])
    print zip(row.rstrip('\n') for (row) in f)

[toc] | [prev] | [next] | [standalone]


#42045

FromJiewei Huang <jiewei24@gmail.com>
Date2013-03-27 15:26 -0700
Message-ID<0696fc8d-5325-438d-82b9-c0f95f8593d5@googlegroups.com>
In reply to#42002
On Wednesday, March 27, 2013 9:18:28 PM UTC+10, rusi wrote:
> On Mar 27, 2:35 pm, Jiewei Huang <jiewe...@gmail.com> wrote:
> 
> > On Tuesday, March 26, 2013 1:48:10 PM UTC+10, MRAB wrote:
> 
> > > 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.
> 
> >
> 
> > > >> >>> <SNIP>
> 
> >
> 
> > > >> >> 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)
> 
> >
> 
> > Hi the output is:
> 
> >
> 
> > [('John Cleese,Ministry of Silly Walks,5555421,27-Oct',), ('Stacy Kisha,Ministry of Man Power,1234567,17-Jan',)]
> 
> >
> 
> > how to make it to
> 
> >
> 
> > [CODE][('John Cleese', 'Ministry of Silly Walks' , '5555421', '27-Oct'), ('Stacy Kisha', 'Ministry of Man Power', '1234567,17-Jan')][/CODE]
> 
> >
> 
> > i need ' ' in all the row and the , to be remove after the date
> 
> 
> 
> Everything you need for this has been answered by Tim, Dave, myself
> 
> (and others?).
> 
> If you are stuck, tell us where.
> 
> If something did not work, tell us what.
> 
> 
> 
> Dont you think if you are asking us to do your homework, you should
> 
> offer us a little fee?
Hi Rusi, 

I'm truly struck and I did mention what did not work and i did follow the link you gave and i did come out with my own code which come out as a same result ( look at the #) however it is not the one i need.

f = open('friends.csv', 'rU') 
for row in f: 
    #print zip([row.rstrip() for (row) in f]) 
    print zip(row.rstrip('\n') for (row) in f)

[toc] | [prev] | [next] | [standalone]


#42052

Fromrusi <rustompmody@gmail.com>
Date2013-03-27 18:24 -0700
Message-ID<3b7f12b2-b394-4c22-a3af-8022df371336@mz7g2000pbb.googlegroups.com>
In reply to#42045
On Mar 28, 3:26 am, Jiewei Huang <jiewe...@gmail.com> wrote:
> On Wednesday, March 27, 2013 9:18:28 PM UTC+10, rusi wrote:
> > On Mar 27, 2:35 pm, Jiewei Huang <jiewe...@gmail.com> wrote:
>
> > > On Tuesday, March 26, 2013 1:48:10 PM UTC+10, MRAB wrote:
>
> > > > 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.
>
> > > > >> >>> <SNIP>
>
> > > > >> >> 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)
>
> > > Hi the output is:
>
> > > [('John Cleese,Ministry of Silly Walks,5555421,27-Oct',), ('Stacy Kisha,Ministry of Man Power,1234567,17-Jan',)]
>
> > > how to make it to
>
> > > [CODE][('John Cleese', 'Ministry of Silly Walks' , '5555421', '27-Oct'), ('Stacy Kisha', 'Ministry of Man Power', '1234567,17-Jan')][/CODE]
>
> > > i need ' ' in all the row and the , to be remove after the date
>
> > Everything you need for this has been answered by Tim, Dave, myself
>
> > (and others?).
>
> > If you are stuck, tell us where.
>
> > If something did not work, tell us what.
>
> > Dont you think if you are asking us to do your homework, you should
>
> > offer us a little fee?
>
> Hi Rusi,
>
> I'm truly struck and I did mention what did not work and i did follow the link you gave and i did come out with my own code which come out as a same result ( look at the #) however it is not the one i need.
>
> f = open('friends.csv', 'rU')
> for row in f:
>     #print zip([row.rstrip() for (row) in f])
>     print zip(row.rstrip('\n') for (row) in f)


>>> s='  John Cleese, Ministry of Silly Walks,5555421,27-Oct  \n'
>>> s.split(',')
['  John Cleese', ' Ministry of Silly Walks', '5555421', '27-Oct  \n']
>>> s.strip().split(',')
['John Cleese', ' Ministry of Silly Walks', '5555421', '27-Oct']
>>>

[toc] | [prev] | [next] | [standalone]


#42053

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-03-28 01:32 +0000
Message-ID<51539db5$0$29998$c3e8da3$5496439d@news.astraweb.com>
In reply to#42052
On Wed, 27 Mar 2013 18:24:24 -0700, rusi wrote:

> On Mar 28, 3:26 am, Jiewei Huang <jiewe...@gmail.com> wrote:
>> On Wednesday, March 27, 2013 9:18:28 PM UTC+10, rusi wrote:
>> > On Mar 27, 2:35 pm, Jiewei Huang <jiewe...@gmail.com> wrote:
>> > > On Tuesday, March 26, 2013 1:48:10 PM UTC+10, MRAB wrote:
>> > > > 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:

Eight levels of attribution. And I count up to nine levels of quoting.

Doesn't anyone have a working backspace key in their editor? Please trim 
your responses to what's needed to establish context, there's no need to 
keep the entire thread duplicated in every post.




-- 
Steven

[toc] | [prev] | [next] | [standalone]


#42000

FromJiewei Huang <jiewei24@gmail.com>
Date2013-03-27 02:35 -0700
Message-ID<mailman.3803.1364377475.2939.python-list@python.org>
In reply to#41850
On Tuesday, March 26, 2013 1:48:10 PM UTC+10, MRAB wrote:
> 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.
> 
> >>
> 
> >> >>> <SNIP>
> 
> >> >> 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)

Hi the output is:

[('John Cleese,Ministry of Silly Walks,5555421,27-Oct',), ('Stacy Kisha,Ministry of Man Power,1234567,17-Jan',)]

how to make it to

[CODE][('John Cleese', 'Ministry of Silly Walks' , '5555421', '27-Oct'), ('Stacy Kisha', 'Ministry of Man Power', '1234567,17-Jan')][/CODE]

i need ' ' in all the row and the , to be remove after the date

[toc] | [prev] | [next] | [standalone]


#42219

FromTim Roberts <timr@probo.com>
Date2013-03-28 21:28 -0700
Message-ID<k16al819j7jii6dmtvue8efmtat5vd5uqi@4ax.com>
In reply to#42000
Jiewei Huang <jiewei24@gmail.com> wrote:
>
>Hi the output is:
>
>[('John Cleese,Ministry of Silly Walks,5555421,27-Oct',), ('Stacy Kisha,Ministry of Man Power,1234567,17-Jan',)]
>
>how to make it to
>
>[CODE][('John Cleese', 'Ministry of Silly Walks' , '5555421', '27-Oct'), ('Stacy Kisha', 'Ministry of Man Power', '1234567,17-Jan')][/CODE]
>
>i need ' ' in all the row and the , to be remove after the date

Do you have any intention of doing ANY of this work on your own?  Or are
you going to steal it all?
-- 
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

[toc] | [prev] | [next] | [standalone]


#41848

FromJiewei Huang <jiewei24@gmail.com>
Date2013-03-25 20:33 -0700
Message-ID<mailman.3712.1364268791.2939.python-list@python.org>
In reply to#41845
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.
> 
> 
> 
> >>> <SNIP>
> 
> >>
> 
> 
> 
> >>
> 
> >>
> 
> >> 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("[", "(")
> 
> 
> 
> -- 
> 
> -- 
> 
> DaveA

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 ?

[toc] | [prev] | [next] | [standalone]


#41809

FromJiewei Huang <jiewei24@gmail.com>
Date2013-03-24 18:15 -0700
Message-ID<a074c53f-f0f4-4dc5-9cf2-3e148e805f3e@googlegroups.com>
In reply to#41767
On Sunday, March 24, 2013 3:20:29 PM UTC+10, Jiewei Huang wrote:

thanks to you guys i got my desire outcome! i will continue to code on writing and saving of csv file 

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.python


csiph-web