<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> </head><p>Sent from my BlackBerry® on the MetroPCS Network</p><hr/><div><b>From: </b> Louis LEICHTNAM &lt;louis.leichtnam@sgcib.com&gt;
</div><div><b>Date: </b>Thu, 24 Mar 2011 11:51:26 -0400</div><div><b>To: </b>&lt;l.leichtnam@gmail.com&gt;</div><div><b>Subject: </b>Fw: [Tutor] Fw: Fw: Parsing data from a csv file [NC]</div><div><br/></div>
<br><font size=1 color=#800080 face="sans-serif">----- Forwarded by Louis
LEICHTNAM/us/socgen on 03/24/2011 11:51 AM -----</font>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>Louis LEICHTNAM/us/socgen</b></font>
<p><font size=1 face="sans-serif">03/24/2011 11:48 AM</font>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif">tutor-bounces+l.leichtnam=gmail.com@python.org,
joel.goldstick@gmail.com, tutor@python.org, rafadurancastaneda@gmail.com</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">Re: Fw: [Tutor] Fw: Fw: Parsing data
from a csv file [NC]</font><a href=Notes:///852577BC000C6413/DABA975B9FB113EB852564B5001283EA/60677866DC5D96E58525785D00560CBB>Link</a></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br><font size=2 face="sans-serif">For example the line 1 in the csv file
is:</font>
<br>
<br><font size=2 face="sans-serif">Barney Gumble, Breakfast, Duffbeer,
1, I could?ve gone to Harvard</font>
<br>
<br><font size=2 face="sans-serif">and I want to be able to clean it and
turn it into:</font>
<br>
<br><font size=2 face="sans-serif">Barney Gumble had for beakfast 1 Duffbeer
while thinking &quot;I coul?ve gone to Harvard&quot;</font>
<br>
<br><font size=2 face="sans-serif">so basically using in this line the
column0 + &quot;had for &quot; + column 1 + column3 + column2 + &quot;while
thinking&quot;+column4</font>
<br>
<br><font size=2 face="sans-serif">and I want to be able to do this for
every line, except for line0.</font>
<br>
<br><font size=2 face="sans-serif">My end game is, after I'm able to do
this, I want to write an Html using python that shows those cleand lines</font>
<br>
<br><font size=2 face="sans-serif">Thanks for your help</font>
<br>
<br>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40% rowspan=2><font size=1 face="sans-serif"><b>l.leichtnam@gmail.com</b>
</font>
<p><font size=1 face="sans-serif">03/24/2011 11:39 AM</font>
<table border>
<tr valign=top>
<td bgcolor=white>
<div align=center><font size=1 face="sans-serif">Please respond to<br>
l.leichtnam@gmail.com</font></div></table>
<br>
<td width=59%>
<tr valign=top>
<td>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif">Louis LEICHTNAM/us/socgen@socgen</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">Fw: [Tutor] Fw: Fw: Parsing data from
a csv file [NC]</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=3>Ok, I think what you are trying is to get all data in
a string list:<br>
<br>
import urllib, csv<br>
url=r&quot;</font><a href=http://www.cs.columbia.edu/~joshua/teaching/cs3101/simpsons_diet.csv><font size=3 color=blue><u>http://www.cs.columbia.edu/~joshua/teaching/cs3101/simpsons_diet.csv</u></font></a><font size=3>&quot;<br>
simpsons=urllib.urlopen(url)<br>
reader=csv.reader(simpsons,delimiter=',',quotechar='&quot;')<br>
<br>
list_string = []<br>
<br>
for char,meal,ate,qty,com in reader:<br>
&nbsp;&nbsp; if char != 'Character':<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; list_string.append(&quot;%s %s %s %s %s&quot;
% (char, meal, ate, qty, com))<br>
<br>
print list_string<br>
<br>
Doing something like this you can format all strings as you want and keep
them into a list<br>
</font>
<br><font size=3>2011/3/24 &lt;</font><a href=mailto:l.leichtnam@gmail.com><font size=3 color=blue><u>l.leichtnam@gmail.com</u></font></a><font size=3>&gt;</font>
<br><font size=3>Thanks, what I'm trying to do is extract the data from
the csv file, clean it to make each line into a sentence.<br>
<br>
But for this I think I need to use a dictionary for each and enter the
words of each columns in one no?</font>
<br><font size=3>Sent from my BlackBerry® on the MetroPCS Network<br>
</font>
<br><font size=3>-----Original Message-----<br>
From: Rafael Durán Castańeda<br>
&nbsp; &nbsp; &nbsp; &nbsp;&lt;</font><a href=mailto:rafadurancastaneda@gmail.com><font size=3 color=blue><u>rafadurancastaneda@gmail.com</u></font></a><font size=3>&gt;<br>
Sender: tutor-bounces+l.leichtnam=</font><a href=http://gmail.com/ target=_blank><font size=3 color=blue><u>gmail.com</u></font></a><font size=3>@</font><a href=http://python.org/ target=_blank><font size=3 color=blue><u>python.org</u></font></a><font size=3><br>
Date: Thu, 24 Mar 2011 15:51:34<br>
To: &lt;</font><a href=mailto:tutor@python.org><font size=3 color=blue><u>tutor@python.org</u></font></a><font size=3>&gt;<br>
Subject: Re: [Tutor] Fw: Fw: Parsing data from a csv file [NC]<br>
<br>
_______________________________________________<br>
Tutor maillist &nbsp;- &nbsp;</font><a href=mailto:Tutor@python.org><font size=3 color=blue><u>Tutor@python.org</u></font></a><font size=3><br>
To unsubscribe or change subscription options:</font><font size=3 color=blue><u><br>
</u></font><a href=http://mail.python.org/mailman/listinfo/tutor target=_blank><font size=3 color=blue><u>http://mail.python.org/mailman/listinfo/tutor</u></font></a><font size=3><br>
</font>
<br>
<br><pre>
*************************************************************************
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.
*************************************************************************
</pre>
</html>