Selectively feeding python csv class with lines
<p>I have a csv file with a few patterns. I only want to selectively load lines into the csv reader class of python. Currently, csv only takes a file object. Is there a way to get around this?<br>
In other words, what I need is:</p>

<pre><code>with open('filename') as f:
    for line in f:
        if condition(line):
            record = csv.reader(line)
</code></pre>

<p>But, currently, csv class fails if it is given a line instead of a file object.</p>

<p>To read file as stream you can use this.</p>

<pre><code>io.open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True)
</code></pre>

python csv