久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

python - pandas html格式的excel文件

瀏覽:135日期:2022-09-20 13:59:46

問題描述

網頁上下載的excel文件,用記事本打開顯示如下:python - pandas html格式的excel文件

用pandas.read_excel讀取的話,提示

XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b’<html x’

假如用excel打開再另存為excel,讀取當然可以,但是有很多excel文件這樣處理就很繁瑣,有沒有什么方法么

VBS處理代碼

Function GetPath()Const WINDOW_HANDLE = 0Const OPTIONS = 0Set objShell = CreateObject('Shell.Application')Set objFolder = objShell.BrowseForFolder(WINDOW_HANDLE, 'Select a folder:', OPTIONS)If objFolder Is Nothing ThenWscript.QuitEnd IfSet objFolderItem = objFolder.SelfGetPath = objFolderItem.PathEnd FunctionFunction SaveToExcel(src_file,dest_file)csv_format = 1 ’6另存為csv,1另存為xlsSet objFSO = CreateObject('Scripting.FileSystemObject')Dim oExcelSet oExcel = CreateObject('Excel.Application')oExcel.DisplayAlerts=falseDim oBookSet oBook = oExcel.Workbooks.Open(src_file)oBook.Worksheets(1).ActivateoBook.SaveAs dest_file, csv_formatoBook.Close FalseoExcel.QuitEnd FunctionDim i : i=0Set oFso = CreateObject('Scripting.FileSystemObject') Set oFolder = oFso.GetFolder(GetPath()) Set oFiles = oFolder.Files For Each oFile In oFilesIf Right(oFile.Path,3)='xls' or Right(oFile.Path,4)='xlsx' Then SaveToExcel oFile.Path,oFile.Pathi=i+1End IfNextMsgBox '總共處理了'&i&'個EXCEL文件'Wscript.Quit

問題解答

回答1:

用vbs打開再另存為EXCEL,再讀取

回答2:

你這個本來就是excel格式干嘛使用文本打開,你下載后直接panda讀就可以了

標簽: python
相關文章:
主站蜘蛛池模板: 唐海县| 汉中市| 通道| 西和县| 微山县| 天水市| 中阳县| 汾阳市| 建水县| 贵南县| 花莲县| 共和县| 太白县| 墨竹工卡县| 清丰县| 涿州市| 乌鲁木齐市| 神木县| 京山县| 阿巴嘎旗| 凤冈县| 友谊县| 开平市| 张家口市| 郸城县| 彭水| 和林格尔县| 忻城县| 连南| 深水埗区| 辽阳市| 淮北市| 定南县| 申扎县| 贡觉县| 方城县| 义乌市| 山东| 大埔区| 偃师市| 万荣县|