using python to encapsulate part of a string after 3 commas
<p>I am trying to create a python script that adds quotations around part of a string, after 3 commas</p>

<p>So if the input data looks like this:</p>

<pre><code>1234,1,1/1/2010,This is a test. One, two, three.
</code></pre>

<p>I want python to convert the string to:</p>

<pre><code>1234,1,1/1/2010,"This is a test. One, two, three."
</code></pre>

<p>The quotes will always need to be added after 3 commas</p>

<p>I am using Python 3.1.2 and have the following so far:</p>

<pre><code>i_file=open("input.csv","r")
o_file=open("output.csv","w")

for line in i_file:
        tokens=line.split(",")
        count=0
        new_line=""
        for element in tokens:
                if count = "3":
                        new_line = new_line + '"' + element + '"'
                        break
                else:
                        new_line = new_line + element + ","
                        count=count+1

        o_file.write(new_line + "\n")
        print(line, " -&gt; ", new_line)

i_file.close()
o_file.close()
</code></pre>

<p>The script closes immediately when I try to run it and produces no output</p>

<p>Can you see what's wrong?</p>

<p>Thanks</p>
