import pandas as pd
def read_data(file_name):
'''
file_name:文件地址
'''
inputfile = open(file_name, 'rb')
data = pd.read_csv(inputfile, iterator=True)
loop = True
chunkSize = 1000
chunks = []
while loop:
try:
chunk = dcs.get_chunk(chunkSize)
chunks.append(chunk)
except StopIteration:
loop = False
print("Iteration is stopped.")
data = pd.concat(chunks, ignore_index=True)
return data
python面试题十(python分块读取大数据,避免内存不足的方法)
猜你喜欢
转载自blog.csdn.net/weixin520520/article/details/105451313
今日推荐
周排行