Python and CSV: find a row and give column value
<p>It consists in creating a function def(,) that searches for the name of the kid in the CSV file and gives his age.</p>

<p>The CSV file is structured as this:</p>

<pre><code>Nicholas,12
Matthew,6
Lorna,12
Michael,8
Sebastian,8
Joseph,10
Ahmed,15 
</code></pre>

<p>while the code that I tried is this:</p>

<pre><code>def fetchcolvalue(kids_agefile, kidname):

    import csv

    file = open(kids_agefile, 'r')
    ct = 0

    for row in csv.reader(file):
        while True:
            print(row[0])
            if row[ct] == kidname:
                break
</code></pre>

<p>The frustrating thing is that it doesn't give me any error, but an infinite loop: I think that's what I'm doing wrong.</p>

<p>So far, what I learnt from the book is only loops (<em>while</em> and <em>for</em>) and if-elif-else cycles, besides CSV and file basic manipulation operations, so I can't really figure out how can I solve the problem with only those tools.</p>

<p>Please notice that the function would have to work with a generic 2-columns CSV file and not only the kids' one.</p>