Unable to filter lines before loading CSV file into pandas object.
You can either upload the file and then filter using df[df['field'] > constant] , or if you have a very large file and are worried about running out of memory, then use an iterator and apply a filter as you combine the pieces of your file, for example:
import pandas as pd iter_csv = pd.read_csv('file.csv', iterator=True, chunksize=1000) df = pd.concat([chunk[chunk['field'] > constant] for chunk in iter_csv])
You can change chunksize according to available memory. See here for more details.
Matti John Nov 30 '12 at 21:31 2012-11-30 21:31
source share