日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

Python读取 xlsb 文件格式

發(fā)布時(shí)間:2024/3/26 61 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python读取 xlsb 文件格式 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

.xlsb 格式是Binary格式存儲(chǔ)的excel文件,比普通的xlsx文件的體積要小很多,在數(shù)據(jù)量極大的場(chǎng)景比較多用。

目前有兩種方式讀取 .xlsb 格式的文件

Pandas

官方文檔:Binary Excel (.xlsb) files

The read_excel() method can also read binary Excel files using the pyxlsb module. The semantics and features for reading binary Excel files mostly match what can be done for Excel files using engine=‘pyxlsb’. pyxlsb does not recognize datetime types in files and will return floats instead.
Currently pandas only supports reading binary Excel files. Writing is not implemented.

import pandas as pd df_excel = pd.read_excel('test.xlsb', engine='pyxlsb',sheet_name='詳細(xì)數(shù)據(jù)')

但如果表中有合并的單元格,則在處理dataframe的時(shí)候會(huì)出錯(cuò),可以用pyxlsb庫(kù)逐行讀取數(shù)據(jù)


pyxlsb

import pyxlsb as px import pandas as pdpath = "test.xlsb" list_row=[] list_accumulate= []# 逐行讀取 with px.open_workbook(path) as wb:sheets = wb.sheetsfor sheet in sheets:row_generator = wb.get_sheet(sheet).rows()for row in row_generator:for cell in row:list_row.append(cell.v)list_accumulate.append(list_row)list_row=[]df_excel = pd.DataFrame(list_accumulate)

參考來(lái)源:使用pyxlsb庫(kù)讀取xlsb格式excel文件,轉(zhuǎn)為DataFrame(詳細(xì))

總結(jié)

以上是生活随笔為你收集整理的Python读取 xlsb 文件格式的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。