On Thu, Mar 24, 2011 at 1:45 PM, <l.leicht...@gmail.com> wrote: > Sent from my BlackBerry® on the MetroPCS Network > ------------------------------ > *From: * Louis LEICHTNAM <louis.leicht...@sgcib.com> > *Date: *Thu, 24 Mar 2011 11:51:26 -0400 > *To: *<l.leicht...@gmail.com> > *Subject: *Fw: [Tutor] Fw: Fw: Parsing data from a csv file [NC] > > > ----- Forwarded by Louis LEICHTNAM/us/socgen on 03/24/2011 11:51 AM ----- > > *Louis LEICHTNAM/us/socgen* > > 03/24/2011 11:48 AM > To > tutor-bounces+l.leichtnam=gmail....@python.org, joel.goldst...@gmail.com, > tutor@python.org, rafadurancastan...@gmail.com > cc > Subject > Re: Fw: [Tutor] Fw: Fw: Parsing data from a csv file > [NC]Link<Notes:///852577BC000C6413/DABA975B9FB113EB852564B5001283EA/60677866DC5D96E58525785D00560CBB> > > > > For example the line 1 in the csv file is: > > Barney Gumble, Breakfast, Duffbeer, 1, I could?ve gone to Harvard > > and I want to be able to clean it and turn it into: > > Barney Gumble had for beakfast 1 Duffbeer while thinking "I coul?ve gone to > Harvard" > > so basically using in this line the column0 + "had for " + column 1 + > column3 + column2 + "while thinking"+column4 > > and I want to be able to do this for every line, except for line0. > > My end game is, after I'm able to do this, I want to write an Html using > python that shows those cleand lines > > Thanks for your help > > If the code below is doing what you like:
list_string.append("%s %s %s %s %s" % (char, meal, ate, qty, com)) change it to this: list_string.append("%s had for %s %s %s while thinking '%s'" % (char, meal, qty, ate, com)) > > *l.leicht...@gmail.com* > > 03/24/2011 11:39 AM > Please respond to > l.leicht...@gmail.com > > To > Louis LEICHTNAM/us/socgen@socgen > cc > Subject > Fw: [Tutor] Fw: Fw: Parsing data from a csv file [NC] > > > > > Ok, I think what you are trying is to get all data in a string list: > > import urllib, csv > url=r"* > http://www.cs.columbia.edu/~joshua/teaching/cs3101/simpsons_diet.csv*<http://www.cs.columbia.edu/%7Ejoshua/teaching/cs3101/simpsons_diet.csv> > " > simpsons=urllib.urlopen(url) > reader=csv.reader(simpsons,delimiter=',',quotechar='"') > > list_string = [] > > for char,meal,ate,qty,com in reader: > if char != 'Character': > list_string.append("%s %s %s %s %s" % (char, meal, ate, qty, com)) > > print list_string > > Doing something like this you can format all strings as you want and keep > them into a list > > 2011/3/24 <*l.leicht...@gmail.com* <l.leicht...@gmail.com>> > Thanks, what I'm trying to do is extract the data from the csv file, clean > it to make each line into a sentence. > > But for this I think I need to use a dictionary for each and enter the > words of each columns in one no? > Sent from my BlackBerry® on the MetroPCS Network > > -----Original Message----- > From: Rafael Durán Castañeda > <*rafadurancastan...@gmail.com* <rafadurancastan...@gmail.com>> > Sender: tutor-bounces+l.leichtnam=*gmail.com* <http://gmail.com/>@* > python.org* <http://python.org/> > Date: Thu, 24 Mar 2011 15:51:34 > To: <*tutor@python.org* <tutor@python.org>> > Subject: Re: [Tutor] Fw: Fw: Parsing data from a csv file [NC] > > _______________________________________________ > Tutor maillist - *Tutor@python.org* <Tutor@python.org> > To unsubscribe or change subscription options:* > **http://mail.python.org/mailman/listinfo/tutor*<http://mail.python.org/mailman/listinfo/tutor> > > > ************************************************************************* > This message and any attachments (the "message") are confidential, intended > solely for the addressee(s), and may contain legally privileged information. > Any unauthorised use or dissemination is prohibited. E-mails are susceptible > to alteration. Neither SOCIETE GENERALE nor any of its subsidiaries or > affiliates shall be liable for the message if altered, changed or falsified. > ************************************************************************* > > -- Joel Goldstick
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor