阿桂天山的小工具:我将16个Excel文件中31万多条数据拆分成318个文件

1.话不多说,先上图看效果

2.技术说明及实用源码

2.1)python+flask+pandas , 由于我的开发环境版本问题,为了能读xls,xlsx,但又不想升级,只能通过xlrd 1.2.0读取xls,xlsx文件再转换成dict字典格式,再通过 data = pd.DataFrame(dict_data)实现类型转换

2.2)实用代码,保证不丢任何一行数据,亲测验证,绝对好用

复制代码
            data = pd.DataFrame(dict_data)

            row_num, column_num = data.shape  # 数据共有多少行,多少列
            print('the sample number is %s and the column number is %s' % (row_num, column_num))
            # 1000行分割
            for i in range(0, (row_num // 1001)+1):
                save_data = data.iloc[i * 1000:(i + 1) * 1000, :]  # 每隔1000循环一次
                split_num = split_num+1
                splitfilename = os.path.join(config.SPLIT_FOLDERFILES, 'split_' + str(split_num) + '.xls')
                print("split file name:",splitfilename)
                save_data.to_excel(splitfilename, sheet_name='Sheet1',  index=False) 
                filenames = filenames + 'split_' + str(split_num) + '.xls '
            filenames = filenames + ';'

2.3)其实重点就三行代码

1000行分割

for i in range(0, (row_num // 1001)+1):
save_data = data.iloc[i * 1000:(i + 1) * 1000, :] # 每隔1000循环一次

save_data.to_excel(splitfilename, sheet_name='Sheet1', index=False)

如果对你有帮助,给个赞吧

相关推荐
Access开发易登软件17 小时前
数据处理中的两大基石:何时选择Excel,何时考虑Access
数据库·信息可视化·excel·vba·access
开开心心就好18 小时前
PDF密码移除工具,免费解除打印编辑复制权限
java·网络·windows·websocket·pdf·电脑·excel
weixin_4624462321 小时前
Python 实战:将 HTML 表格一键导出为 Excel(xlsx)
linux·python·excel·pandas
Data-Miner1 天前
Excel-Agent永久买断,一款结合AI Agent的excel数据处理智能体
人工智能·excel
weixin_462446231 天前
Python 使用 openpyxl 从 URL 读取 Excel 并获取 Sheet 及单元格样式信息
python·excel·openpyxl
wtsolutions1 天前
MCP Server Integration - JSON to Excel for AI and Automation
json·excel
开开心心就好2 天前
音频编辑工具,多端支持基础剪辑易操作
java·网络·windows·java-ee·电脑·maven·excel
vfvfb2 天前
excel多个合并 xlsx工作表合并 多个excel合并到一张表
excel
金融小白数据分析之路2 天前
msoffcrypto-tool库 Excel 加密
python·excel
开开心心_Every2 天前
文件数量统计工具:支持多层文件夹数量统计
游戏·微信·pdf·excel·语音识别·swift·lisp