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 -- http://mail.python.org/mailman/listinfo/python-list