python with pandas:文件大小(44546)不是512+扇区大小的倍数(512) [英] python with pandas: file size (44546) not 512 + multiple of sector size (512)

查看:36
本文介绍了python with pandas:文件大小(44546)不是512+扇区大小的倍数(512)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用pandas读取excel文件后,得到如下警告:

After read excel file with pandas, gets the follow warning:

关键代码:

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) 在没有最终解决的情况下被打开和关闭.但是,讨论确实提供了一种替代方法,可以让您抑制警告:

This appears to be a normal warning from the underlying XLRD library, and it seems safe to ignore. A pandas issue (#16620) was opened and closed without a conclusive resolution. However, the discussion did provide an alternative that would allow you to suppress the warnings:

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

You can read a more detailed analysis of the actual cause of the error on the forum here: https://groups.google.com/forum/m/#!topic/python-excel/6Lue-1mTPSM

故事的寓意:每当您收到不确定的警告时,您应该搜索出现的关键字(丢弃任何特定部分,如文件大小或本地路径).此答案基于在 Google 上显示的前两个结果.

Moral of the story: whenever you get a warning you aren't sure about, you should search for the keywords that appear (discard any specific parts like file sizes or local paths). This answer is based on the first two results to show up on Google.

这篇关于python with pandas:文件大小(44546)不是512+扇区大小的倍数(512)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆