duckdb excel插件和rusty_sheet插件在python中的不同表现

  1. 建立虚拟环境
    安装python扩展包duckdb、polars和pandas

    python -m venv pwin313
    pwin313\scripts\activate.bat
    pwin313)C:\d\pwin313>pip install duckdb polars pandas

  2. 在python中引入扩展包,安装加载duckdb插件

    pwin313) C:\d\pwin313>python
    Python 3.13.2 (tags/v3.13.2:4f8bb39, Feb 4 2025, 15:23:48) [MSC v.1942 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.

    import duckdb
    duckdb.sql("install excel")
    duckdb.sql("install rusty_sheet from community")
    import time

    duckdb.sql("load excel")
    duckdb.sql("load rusty_sheet")

rusty_sheet是 v0.4.2版。

分别测试两种插件不转成数据框和转成polars、duckdb数据框

复制代码
>>> t=time.time();duckdb.sql("select * from read_xlsx('/d/lineitem.xlsx')");t1=time.time();print(t1-t)
0.3100736141204834
>>> t=time.time();duckdb.sql("select * from read_xlsx('/d/lineitem.xlsx')").pl();t1=time.time();print(t1-t)
4.7497313022613525
>>> t=time.time();duckdb.sql("select * from read_xlsx('/d/lineitem.xlsx')").fetchdf();t1=time.time();print(t1-t)
4.8916003704071045


>>> t=time.time();duckdb.sql("select * from read_sheet('/d/lineitem.xlsx',range='2:')");t1=time.time();print(t1-t)
4.251304626464844
>>> t=time.time();duckdb.sql("select * from read_sheet('/d/lineitem.xlsx',range='2:')").pl();t1=time.time();print(t1-t)
9.083962440490723
>>> t=time.time();duckdb.sql("select * from read_sheet('/d/lineitem.xlsx',range='2:')").fetchdf();t1=time.time();print(t1-t)
9.565066576004028

可见,read_xlsx不转数据框,则不实际读取数据,而read_sheet读取。

相关推荐
人道领域1 小时前
【黑马点评日记】高并发秒杀:库存超卖与锁机制解析
java·开发语言·redis·spring·intellij-idea
lsx2024062 小时前
《jEasyUI 创建树形下拉框》
开发语言
pele2 小时前
如何解决多线图中线条颜色不渲染(仅标记和提示框显示颜色)的问题
jvm·数据库·python
minji...2 小时前
Linux 网络套接字编程(一)端口号port,socket套接字,socket,bind,socket 通用结构体
linux·运维·服务器·开发语言·网络
forEverPlume2 小时前
golang如何排查大量goroutine性能问题_golang大量goroutine性能排查详解
jvm·数据库·python
2301_814809862 小时前
踩坑实战pywebview:用 Python + Web 技术打造轻量级桌面应用
开发语言·前端·python
南境十里·墨染春水2 小时前
C++流类库 字符串流
开发语言·c++
2401_883600252 小时前
Golang怎么CGO交叉编译_Golang如何在交叉编译时处理CGO依赖问题【避坑】
jvm·数据库·python
smj2302_796826522 小时前
解决leetcode第3906题统计网格路径中好整数的数目
python·算法·leetcode