Read a column then write in another column from a CSV file with Python
<p>I have a CSV file which contains 10 lines and 5 column.</p>

<p>For each lines, excepted first line, 
I need to read column 2 and to recognize the beginning or the end of the cell.
Depending on what the script reads on each column 2, it writes a letter in colomn 6 from the same line.</p>

<p>Thank a lot in advance if you can help me !</p>

<p>Here is my code : </p>

<pre><code>with open('test.csv', 'rb') as u:
        read = csv.reader(u)
        for line in read:
            for row[2] in rows:
                if line.endswith('this_is_a_text'):
                    writer.writerow(row[6]+["WIN"])
</code></pre>

<p>If that is your actual code, you do not have the variable "rows" available at the current scope. You have 'line'. Perhaps you mean something to the effect of </p>

<pre><code>for row in reader
</code></pre>

<p>?? The documentation I'm reading says that a line is a row, there should be columns in your line/row.</p>

python csv pandas data-science