<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div></div><div><br><div>Begin forwarded message:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" color="#000000" style="font: 12.0px Helvetica; color: #000000"><b>From: </b></font><font face="Helvetica" size="3" style="font: 12.0px Helvetica">W W &lt;<a href="mailto:srilyk@gmail.com">srilyk@gmail.com</a>></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" color="#000000" style="font: 12.0px Helvetica; color: #000000"><b>Date: </b></font><font face="Helvetica" size="3" style="font: 12.0px Helvetica">29 January 2009 11:43:37 GMT</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" color="#000000" style="font: 12.0px Helvetica; color: #000000"><b>To: </b></font><font face="Helvetica" size="3" style="font: 12.0px Helvetica">"emmanuel.delaborde" &lt;<a href="mailto:emmanuel.delaborde@cimex.com">emmanuel.delaborde@cimex.com</a>></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" color="#000000" style="font: 12.0px Helvetica; color: #000000"><b>Cc: </b></font><font face="Helvetica" size="3" style="font: 12.0px Helvetica"><a href="mailto:tutor@python.org">tutor@python.org</a></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" color="#000000" style="font: 12.0px Helvetica; color: #000000"><b>Subject: </b></font><font face="Helvetica" size="3" style="font: 12.0px Helvetica"><b>Re: [Tutor] Problem with nested for-in</b></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div> </div><div class="gmail_quote">On Thu, Jan 29, 2009 at 5:06 AM, emmanuel.delaborde <span dir="ltr">&lt;<a href="mailto:emmanuel.delaborde@cimex.com">emmanuel.delaborde@cimex.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> Hello,<br> <br> I have the following snippet :<br> <br> lines = csv.reader(open("CATEGORY.csv","r"))<br> lines2 = csv.reader(open("CATEGORYLIST.csv","r"))<br> <br> old_cats = []<br> for line in lines:</blockquote><div>&nbsp;&nbsp; &nbsp; &nbsp;print line&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br> &nbsp; &nbsp;stories = []<br> &nbsp; &nbsp;for line2 in lines2:</blockquote><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print line2&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br> &nbsp; &nbsp; &nbsp; &nbsp;if line2[1] == line[0]:<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stories.append(line2[0])<br> &nbsp; &nbsp;old_cats.append((line[0],line[2], stories))<br> <br> <br> what happens is that<br> <br> for the first elt of lines, the nested for in runs fine<br> but then never seem to run again while the top level loop iterates through the rest of lines<br> <br> consequently stories accumulate nothing...<br> <br> Can someone explain please ?<br></blockquote></div><br> <div>I would try adding the two print statements above to your code. It might give you an idea about what's going on. It would also be helpful to provide us with some of your original data and the data you get once you've run the program.</div> <div><br></div><div>HTH,</div><div>Wayne</div></blockquote></div><div><br></div><div><br></div><div><br></div></div></body></html>
<pre>-----------------------------------------------------------------------------------------------

This e-mail (and any attachments) is confidential and may contain 
personal views which are not the views of Cimex Media Ltd and 
any affiliated companies, unless specifically stated. It is intended 
for the use of the individual or group to whom it is addressed. If 
you have received it in error, please delete it from your system, 
do not use, copy or disclose the information in any way nor act in 
reliance on it and please notify postmaster@cimex.com

A company registered in England  Wales. Company Number 03765711
Registered Office : The Olde Bakehouse, 156 Watling Street East, Towcester,
Northants NN12 6DB

This email was scanned by Postini, the leading provider in Managed Email Security.