pandas python 读取大文件

data = pd.read_csv('*****.csv',iterator=True)
loop = True
chunkSize = 1000000
chunks = []
while loop:
    try:
        chunk = data.get_chunk(chunkSize)
        #break
        chunk = chunk[['companyId:ID(Company-ID)',':LABEL','company_name']]
        chunk.to_csv(path,index=False,mode='a',header=0)
    except StopIteration:
        loop = False
        print("Iteration is stopped.")
#df = pd.concat(chunks, ignore_index=True)
chunk.head()

 

posted @ 2021-02-25 15:06  cup_leo  阅读(373)  评论(0编辑  收藏  举报