I have a file with >5 million rows and 20 fields. I would like to open it in Pandas, but got an out of memory error:
pandas.parser.CParserError: Error tokenizing data. C error: out of memory
I have then read up some posts on similar issues and discovered Blaze, but following three methods (.Data, .CSV, .Table), none worked apparently.
# coding=utf-8
import pandas as pd
from pandas import DataFrame, Series
import re
import numpy as np
import sys
import blaze as bz
reload(sys)
sys.setdefaultencoding('utf-8')
# Gave an out of memory error
'''data = pd.read_csv('file.csv', header=0, encoding='utf-8', low_memory=False)
df = DataFrame(data)
print df.shape
print df.head'''
data = bz.Data('file.csv')
# Tried the followings too, but no luck
'''data = bz.CSV('file.csv')
data = bz.Table('file.csv')'''
print data
print data.head(5)
Output:
_1
_1.head(5)
[Finished in 1.0s]