[Tutor] Fw: Fw: Fw: Parsing data from a csv file [NC]

l.leichtnam at gmail.com l.leichtnam at gmail.com
Thu Mar 24 16:53:18 CET 2011

Sent from my BlackBerry® on the MetroPCS Network

-----Original Message-----
From: Louis LEICHTNAM <louis.leichtnam at sgcib.com>
Date: Thu, 24 Mar 2011 11:51:26 
To: <l.leichtnam at 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

tutor-bounces+l.leichtnam=gmail.com at python.org, joel.goldstick at gmail.com, 
tutor at python.org, rafadurancastaneda at gmail.com

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.leichtnam at gmail.com 
03/24/2011 11:39 AM
Please respond to
l.leichtnam at gmail.com

Louis LEICHTNAM/us/socgen at socgen

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

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.leichtnam at 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
       <rafadurancastaneda at gmail.com>
Sender: tutor-bounces+l.leichtnam=gmail.com at python.org
Date: Thu, 24 Mar 2011 15:51:34
To: <tutor at python.org>
Subject: Re: [Tutor] Fw: Fw: Parsing data from a csv file [NC]

Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:

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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110324/d32f2af0/attachment-0001.html>

More information about the Tutor mailing list