python 和 pandas:文件大小 (44546) 不是 512 + 扇区大小 (512) 的倍数
python with pandas: file size (44546) not 512 + multiple of sector size (512)
使用 pandas 读取 excel 文件后,收到以下警告:
关键代码:
pd_obj = pd.read_excel("flie.xls", dtype=str, usecols=usecols, skiprows=3)
for idx, row in pd_obj.iterrows():
json_tmpl = copy.deepcopy(self.details)
json_tmpl["nameInBank"] = row["nameInBank"]
json_tmpl["totalBala"] = row["totalBala"].replace(",", '')
# parse pdf file
status = self._get_banksplip_json(json_tmpl["bankReceipts"], row)
json_buf.append(copy.deepcopy(json_tmpl))
警告信息:
WARNING *** file size (48130) not 512 + multiple of sector size (512)
WARNING *** file size (44546) not 512 + multiple of sector size (512)
这似乎是来自底层 XLRD 库的正常警告,忽略它似乎是安全的。 pandas 个问题 (#16620) 在没有最终解决方案的情况下被打开和关闭。但是,讨论确实提供了一种替代方法,可以让您抑制警告:
from os import devnull
import pandas as pd
import xlrd
wb = xlrd.open_workbook('file.xls', logfile=open(devnull, 'w'))
pd_obj = pd.read_excel(wb, dtype=str, usecols=usecols, skiprows=3, engine='xlrd')
您可以在此处的论坛上阅读更详细的错误实际原因分析:https://groups.google.com/forum/m/#!topic/python-excel/6Lue-1mTPSM
故事的寓意:每当您收到不确定的警告时,您应该搜索出现的关键字(丢弃任何特定部分,如文件大小或本地路径)。此答案基于 Google.
上显示的前两个结果
使用 pandas 读取 excel 文件后,收到以下警告:
关键代码:
pd_obj = pd.read_excel("flie.xls", dtype=str, usecols=usecols, skiprows=3)
for idx, row in pd_obj.iterrows():
json_tmpl = copy.deepcopy(self.details)
json_tmpl["nameInBank"] = row["nameInBank"]
json_tmpl["totalBala"] = row["totalBala"].replace(",", '')
# parse pdf file
status = self._get_banksplip_json(json_tmpl["bankReceipts"], row)
json_buf.append(copy.deepcopy(json_tmpl))
警告信息:
WARNING *** file size (48130) not 512 + multiple of sector size (512)
WARNING *** file size (44546) not 512 + multiple of sector size (512)
这似乎是来自底层 XLRD 库的正常警告,忽略它似乎是安全的。 pandas 个问题 (#16620) 在没有最终解决方案的情况下被打开和关闭。但是,讨论确实提供了一种替代方法,可以让您抑制警告:
from os import devnull
import pandas as pd
import xlrd
wb = xlrd.open_workbook('file.xls', logfile=open(devnull, 'w'))
pd_obj = pd.read_excel(wb, dtype=str, usecols=usecols, skiprows=3, engine='xlrd')
您可以在此处的论坛上阅读更详细的错误实际原因分析:https://groups.google.com/forum/m/#!topic/python-excel/6Lue-1mTPSM
故事的寓意:每当您收到不确定的警告时,您应该搜索出现的关键字(丢弃任何特定部分,如文件大小或本地路径)。此答案基于 Google.
上显示的前两个结果