解决Python报错ValueError: No engine for filetype: ‘xls‘

这篇具有很好参考价值的文章主要介绍了解决Python报错ValueError: No engine for filetype: ‘xls‘。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Python环境介绍

Python3.11,编译器Pycharm 2022.3

报错原因分析

对应Python3.11版本的Pandas无法兼容低版本的xls。

解决Python报错ValueError: No engine for filetype: ‘xls‘,数据处理笔记,python,pycharm,开发语言解决Python报错ValueError: No engine for filetype: ‘xls‘,数据处理笔记,python,pycharm,开发语言

 

 

解决方案

  • 以csv格式输出。
  • 以xlsx格式输出。更改后可能会出现报错,没有安装openxls库,这时,只需安装该库即可正常运行。

解决Python报错ValueError: No engine for filetype: ‘xls‘,数据处理笔记,python,pycharm,开发语言 文章来源地址https://www.toymoban.com/news/detail-519026.html

更正后代码

# 水情日报 数据下载
# Water information data download


# Water information url
# http://61.163.88.227:8006/hwsq.aspx?sr=0nkRxv6s9CTRMlwRgmfFF6jTpJPtAv87


# Design by HanLin


# Parameters start =======

# Start date (include)开始日期
Start_date = '2003-05-20'
# End date (include)结束日期
End_date = '2003-06-24'
# Result save path保存路径
# (Under the Download_data folder)
Save_path = r'F:\water'  #自己更改一下

# Parameters end =======


import warnings
warnings.filterwarnings('ignore')


import os
import sys
import numpy as np
import pandas as pd
import bs4
from bs4 import BeautifulSoup
import requests
import datetime


Water_info_url=r'http://61.163.88.227:8006/hwsq.aspx?sr=0nkRxv6s9CTRMlwRgmfFF6jTpJPtAv87'


# Initial login header
# In order to achieve cookie
header_first={
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-TW;q=0.6',
    'Cache-Control': 'max-age=0',
    'Connection': 'keep-alive',
    'Host': '61.163.88.227:8006',
    'Upgrade-Insecure-Requests': '1',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.64',
}


# Secondary head
# In order to send a search request发送搜索请求
header_next={
    'Accept': '*/*',
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-TW;q=0.6',
    'Cache-Control': 'no-cache',
    'Connection': 'keep-alive',
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    'Host': '61.163.88.227:8006',
    'Origin': r'http://61.163.88.227:8006',
    'Referer': 'http://61.163.88.227:8006/hwsq.aspx?sr=0nkRxv6s9CTRMlwRgmfFF6jTpJPtAv87',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Safari/537.36 Edg/103.0.1264.37',

}


# Data to be transferred要传输的数据
# Use Form Data
postdata={
    'ctl00$ScriptManager1': 'ctl00$ScriptManager1|ctl00$ContentLeft$Button1',
    '__EVENTTARGET': '',
    '__EVENTARGUMENT': '',
    'ctl00$ContentLeft$menuDate1$TextBox11': '2022-06-13',
    '__VIEWSTATE':'/wEPDwULLTEwMDI5NzA1NzkPZBYCZg9kFgICAw9kFgICBQ9kFgJmD2QWAgIBD2QWAgIBDxYCHglpbm5lcmh0bWwF60w8dGFibGUgd2lkdGg9Ijk4JSIgYm9yZGVyPSIwIiBjZWxscGFkZGluZz0iMCIgY2VsbHNwYWNpbmc9IjEiIGJnY29sb3I9IiNEMUREQUEiIGFsaWduPSJjZW50ZXIiPjx0cj48dGQgaGVpZ2h0PSI0MCIgYmFja2dyb3VuZD0ic2tpbi9pbWFnZXMvbmV3bGluZWJnMy5naWYiPjx0YWJsZSB3aWR0aD0iOTglIiBib3JkZXI9IjAiIGNlbGxzcGFjaW5nPSIwIiBjZWxscGFkZGluZz0iMCI+PHRyPjx0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ZD48dGQ+LTwvdGQ+PC90cj48dHIgYWxpZ249ImNlbnRlciIgYmdjb2xvcj0iI0ZGRkZGRiI+PHRkPum7hOaysyAgICAgICAgICAgICAgICAgICAgICAgICAgPC90ZD48dGQ+6Im+5bGxICAgICAgICAgICAgICAgICAgICAgICAgICA8L3RkPjx0ZD4zOC40NDwvdGQ+PHRkPjMxNDA8L3RkPjx0ZD4qNi4zOTwvdGQ+PC90cj48dHIgYWxpZ249ImNlbnRlciIgYmdjb2xvcj0iI0ZGRkZGRiI+PHRkPum7hOaysyAgICAgICAgICAgICAgICAgICAgICAgICAgPC90ZD48dGQ+5rO65Y+jICAgICAgICAgICAgICAgICAgICAgICAgICA8L3RkPjx0ZD4yNi45NjwvdGQ+PHRkPjMwMjA8L3RkPjx0ZD4qNC4wMzwvdGQ+PC90cj48dHIgYWxpZ249ImNlbnRlciIgYmdjb2xvcj0iI0ZGRkZGRiI+PHRkPum7hOaysyAgICAgICAgICAgICAgICAgICAgICAgICAgPC90ZD48dGQ+5Yip5rSlICAgICAgICAgICAgICAgICAgICAgICAgICA8L3RkPjx0ZD4xMC40PC90ZD48dGQ+MjcxMDwvdGQ+PHRkPio2Ljc4PC90ZD48L3RyPjwvdGFibGU+PC90ZD48L3RyPjwvdGFibGU+ZGQX7a8AK6EFHourJJ2xgJ7zGGznTXSzg7yZvMnSVM0/Mw==',
    '__VIEWSTATEGENERATOR': 'E4DC7756',
    '__EVENTVALIDATION': '/wEdAAPgMurU7dGbCJhtK8P1Nstr9DkLBAR+UXBBGQ1m5cY+HY5Ggl8DGIT46Qo2GBY6Yh4fpd+LHAI2ihOULO1i+2DgH5H5WRTn9WanmVpiptZGnA==',
    '__ASYNCPOST': 'true',
    'ctl00$ContentLeft$Button1': '查询',
}



# Parameters that don't seem to be useful
param={
    'sr': '0nkRxv6s9CTRMlwRgmfFF6jTpJPtAv87'
}


def Generate_date_list(start_date,end_date):

    date_lists=[]

    start_date=datetime.datetime.strptime(start_date,'%Y-%m-%d')
    end_date=datetime.datetime.strptime(end_date,'%Y-%m-%d')
    # Make sure the start time is less than the end time#确保开始时间小于结束时间
    if start_date > end_date:
        print('Start time is greater than end time !')
        sys.exit(0)
    else:
        while(start_date <= end_date):
            date_lists.append(datetime.datetime.strftime(start_date,'%Y-%m-%d'))
            start_date=start_date+datetime.timedelta(days=1)

    return date_lists


# Generate postdata corresponding to the date
def Generate_date_related_postdata(postdata,date):
    postdata['ctl00$ContentLeft$menuDate1$TextBox11']=date


def Information_extraction(response):

    response_lists=[]

    # Parsing html
    response = BeautifulSoup(response,'html.parser')

    # Data cleaning
    for single_response in response.find_all('tr'):
        if len(single_response) == 5:
            if isinstance(single_response.contents[0],bs4.element.Tag):

                response_contents_lists=[]

                for single_response_content in single_response.contents:
                    single_response_content_cache=single_response_content.contents
                    if len(single_response_content_cache)!=0:
                        response_contents_lists.append(single_response_content_cache[0])

                response_lists.append(response_contents_lists)

    return response_lists


def Generate_excel(information_lists):
    column_header=information_lists[0]
    Result_excel=pd.DataFrame(information_lists[1:],dtype=str,columns=column_header)


    return Result_excel


def Result_save(save_path,result_excel,date):

    dir_name = 'Download_data'

    file_path = os.path.join(save_path,dir_name)

    # Check if the folder is in
    if not os.path.exists(file_path):
        os.makedirs(file_path)

    file_name = f'{date}.xlsx' ## "xls" was replaced by "xlsx".

    file_path = os.path.join(file_path,file_name)

    result_excel.to_excel(file_path,header=True,index=True)


if __name__=='__main__':

    date_lists = Generate_date_list(Start_date,End_date)

    session = requests.session()
    First_response = session.post(Water_info_url,headers=header_first)

    for date_list in date_lists:

        Generate_date_related_postdata(postdata,date_list)

        Next_response = session.post(Water_info_url, headers=header_next, data=postdata)

        Next_response.raise_for_status()
        Next_response.encoding = Next_response.apparent_encoding
        # Get the returned infomation
        Next_response = Next_response.text

        Information_lists = Information_extraction(Next_response)

        Result_excel = Generate_excel(Information_lists)

        Result_save(Save_path,Result_excel,date_list)

        print(f'Date : {date_list} ,data download is complete !')

到了这里,关于解决Python报错ValueError: No engine for filetype: ‘xls‘的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 已解决ValueError: Excel file format cannot be determined, you must specify an engine manually.

    已解决ValueError: Excel file format cannot be determined, you must specify an engine manually. 粉丝群里面的一个小伙伴遇到问题跑来私信我,想用Pandas读取Excel,但是发生了报错(当时他心里瞬间凉了一大截,跑来找我求助,然后顺利帮助他解决了,顺便记录一下希望可以帮助到更多遇到这个

    2024年02月02日
    浏览(40)
  • python报错:ERROR: No matching distribution found for

      使用pip安装包时提示报错如下: ERROR: Could not find a version that satisfies the requirement package (from versions: none) ERROR: No matching distribution found for package 大多数是网络问题,替换使用国内的镜像来源加速即可。 打开cmd 输入  按回车执行命令后,安装成功。 例如:  

    2024年02月15日
    浏览(49)
  • ValueError: No GFPGAN model found解决方案

    本文收录于《AI绘画从入门到精通》专栏,专栏总目录:点这里,订阅后可阅读专栏内所有文章。 大家好,我是水滴~~ 本文主要介绍在使用 Stable Diffusion WebUI 的附加功能(Extras)中的面部修复(GFPGAN)时,出现的 ValueError: No GFPGAN model found 异常的解决方案。希望能够帮到你。

    2024年04月26日
    浏览(20)
  • 【已解决】vue报错:Parsing error: No Babel config file detected for...

    Vue项目报错:Parsing error: No Babel config file detected… 解决方法:在 package.json 里面添加 \\\"requireConfigFile\\\": false 即可。

    2024年02月15日
    浏览(46)
  • 【JAVA swagger】解决No mapping for GET /swagger-ui.html报错

    完整代码在最后 一、报错 1.网页报错404 2.代码报错 No mapping for GET /swagger-ui.html 二、解决办法 1.版本回退 之前用的是swagger3.0.0和springboot3.0.6,始终没找到合适的解决办法,故将版本回退至swagger2.9.2和springboot2.7.11 2.Spring Boot 2.6.X后与Swagger有版本冲突问题,需要在application.prope

    2024年02月11日
    浏览(50)
  • 无法加载响应数据no data found for resource with given identifier报错解决

    第一种:跨域问题 跨域的解决办法很多,这里不作阐述; 第二种:数据库被锁定,导致长时间未返回结果; 问题描述: 无法加载响应数据no data found for resource with given identifier 生产环境项目实施人员反馈到开发组,有一个用户登录不进去,但是其它用户可以正常登录; 排查

    2024年02月01日
    浏览(48)
  • 解决报错ERROR: No matching distribution found for torchvision==0.11.2+cu111

    目录 一、猜测 二、验证 三、解决方案 四、检验 该报错是在按官网方法用指令: 安装pytorch时出现的,以下是分析: 这个错误提示表明在指令提供的下载网址上没有找到符合要求的torchvision软件包版本,需要安装符合要求的版本。问题可能出在指定的版本号(0.11.2+cu111),这

    2024年02月11日
    浏览(39)
  • 解决:python+appium报错ValueError: Timeout value connect was <...>, but it must be an int, float or None.

    pip install --force-reinstall -v \\\"selenium==4.8.0\\\" 参考: python - Running an keyword on Robotframework throw an error: ValueError: Timeout value connect was object object at 0x106cc5b50 - Stack Overflow ValueError: Timeout value connect was object object at 0x7f7515f84420, but it must be an int, float or None. · Issue #863 · appium/python-client

    2024年02月11日
    浏览(79)
  • Selenium安装报错:No matching distribution found for selenium。经个人尝试,问题已得到解决

    常规的安装方法: a、pippip install selenium b、pip install --index https://mirrors.ustc.edu.cn/pypi/web/simple/ selenium c、pip --default - timeout=100 install selenium d、其他的映射路径……………… 如果上面几种方法都会报错同样的错误:No matching distribution found for selenium(from versions:one)  网上找了很

    2024年02月02日
    浏览(41)
  • python chinesecalendar报错:“no available data for year {}, only year between [{}, {}] supported“

    “no available data for year {}, only year between [{}, {}] supported”. NotImplementedError: no available data for year 2023, only year between [2004, 2022] supported 由于次年的节假日安排,取决于国务院发布的日程。 所以chinesecalendar项目一般会在国务院更新以后,发布新的版本。 按照以往的经验,一般是每年

    2024年02月09日
    浏览(35)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包