Sklearn: 'str' object has no attribute 'read'
<p>I want to use Sklearn to vectorize my data in a big csv file, I used the following code:</p>

<p>First TRY:</p>

<pre><code>from sklearn.feature_extraction.text import CountVectorizer

vectorizer = CountVectorizer(input='file', stop_words = 'english', ngram_range=(1,2))

vectorizer.fit_transform('test.csv')
</code></pre>

<p>But I got this error:</p>

<p>AttributeError: 'str' object has no attribute 'read'</p>

<p>Second TRY, but error was still raised:</p>

<pre><code>import csv

file = open('test.csv', 'r')

f = file.readline()

vectorizer.fit_transform(f)
</code></pre>

<p>Third TRY: This one did work, but it was killed due to out of memory.</p>

<pre><code>file = open('test.csv', 'r')
a = file.read()
vectorizer = TfidfVectorizer(stop_words = 'english', ngram_range=(1,2))
de = vectorizer.fit_transform(a.split('\n'))
</code></pre>

<p>How to use fit_transform in Sklearn to process a large CSV file?</p>