Oops, accidentally replied off-list.<br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Luke Paireepinart</b> <span dir="ltr">&lt;<a href="mailto:rabidpoobear@gmail.com">rabidpoobear@gmail.com</a>&gt;</span><br>
Date: Thu, Oct 8, 2009 at 3:36 PM<br>Subject: Re: [Tutor] Troubles with lists and control flow<br>To: Eduardo Vieira &lt;<a href="mailto:eduardo.susan@gmail.com">eduardo.susan@gmail.com</a>&gt;<br><br><br><br><br><div class="gmail_quote">
<div class="im">On Thu, Oct 8, 2009 at 2:42 PM, Eduardo Vieira <span dir="ltr">&lt;<a href="mailto:eduardo.susan@gmail.com" target="_blank">eduardo.susan@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

Hello I&#39;m developing a script to compare two files, finding duplicate<br>
entries and matching which id of one csv file corresponds to the id of<br>
another csv file.<br>
The first version was working nice, but I wanted to postpone the<br>
writing to a file till the end and also make a correct csv file. The<br>
code is not so great and I expect to work with no more than 3000 lines<br>
of data in either file:<br>
So here is the inicial code. I hope it&#39;s not too long or complicated:<br></blockquote></div><div><br>It&#39;s a little long to be in a message body, it&#39;d have been nice if you posted to pastebin and chosen Python so we could have seen it with syntax highlighting and it would guarantee it doesn&#39;t mess up your indentation, but it&#39;s fine for now.  Just keep that in mind for longer code samples.<br>

<br></div><div class="im"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
def inbv(currentline = None):<br>
    &quot;&quot;&quot;writes a line of data when a date is found in BV&quot;&quot;&quot;<br>
    if currentline is None:<br>
        currentline = []<br>
    else:<br>
        currentline.append(item[&#39;USER_ID&#39;])<br>
        currentline.append(row[&#39;CUS_NO&#39;])<br>
        currentline.append(item[&#39;COMPANY&#39;])<br>
        currentline.append(row[&#39;BVADDR1&#39;])<br>
        currentline.append(item[&#39;ADDRESSLINEONE&#39;])<br>
        currentline.append(row[&#39;BVADDRTELNO1&#39;])<br>
        currentline.append(item[&#39;PHONE&#39;])<br>
        currentline.append(row[&#39;BVCITY&#39;])<br>
        currentline.append(item[&#39;CITY&#39;])<br>
<br>
    return currentline<br></blockquote></div><div>You don&#39;t want to do it like this.<br>What you&#39;re saying is:<br>&quot;if they didn&#39;t pass in an argument to my function, create a new list and return an empty list.  otherwise, if they did pass in a list, append an item and return the new list.&quot;  What you really want to do is &quot;if they didn&#39;t pass in a list, create a new one.  Then append a value and return  the new list.&quot;  There&#39;s a subtle difference, do you see it? You want to add an item to the list whether or not they passed in a list in the first place, you just want to initialize a new list first.  Think about your code and how you can change it to do that.<br>

<br>At least I think that&#39;s what your issue is, I don&#39;t really understand your code at all.<br><br>Also:<br></div><div class="im"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


<br>
def notinbv(currentline):<br>
    if currentline is None:<br>
        currentline = []</blockquote></div><div><br>You should go ahead and define this one the same as the previous one (with the optional currentline parameter) unless you left it out on purpose.<br><br>-Luke <br></div>
</div>
</div><br>