Sent from my BlackBerry® on the MetroPCS Network -----Original Message----- From: Louis LEICHTNAM <louis.leicht...@sgcib.com> Date: Thu, 24 Mar 2011 11:51:26 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] 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 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 " 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> 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> Sender: tutor-bounces+l.leichtnam=gmail....@python.org Date: Thu, 24 Mar 2011 15:51:34 To: <tutor@python.org> Subject: Re: [Tutor] Fw: Fw: Parsing data from a csv file [NC] _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: 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. *************************************************************************
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor