#超大csv按条数分sheet写到excel,name为csv文件名,nums为分割条数
def big_csv_to_xlsx(name,nums):
    #拆分csv
    max_rows = nums
    dataframes = []
    df=pd.read_csv(name+'.csv')
    while len(df) > max_rows:
        top = df[:max_rows]
        dataframes.append(top)
        df = df[max_rows:]
    else:
        dataframes.append(df)
    #保存到不同sheet
    write = pd.ExcelWriter(name+'.xlsx')
    for _, frame in enumerate(dataframes):
        frame.to_excel(write, index=False,sheet_name=str(_))
    write.save()
    write.close()
最后修改:2020 年 09 月 10 日 10 : 57 AM
赏包辣条吧