python - pandas html格式的excel文件
問題描述
網(wǎng)頁上下載的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讀就可以了
相關(guān)文章:
1. ddos - apache日志很多其它網(wǎng)址,什么情況?2. 怎么在phpstudy中用phpexcel上傳數(shù)據(jù)到MYSQL?3. javascript - 百度搜索網(wǎng)站,如何讓搜索結(jié)果顯示一張圖片加上一段描述,如圖;求教4. 二維數(shù)組怎么重新組合5. docker綁定了nginx端口 外部訪問不到6. vue.js - centos 使用vue-cli. 執(zhí)行npm run dev 報錯7. php由5.3升級到5.6后,登錄網(wǎng)站,返回的是php代碼,不是登錄界面,各位大神有知道的嗎?8. javascript - 如何在同一臺電腦上配置不同主機的2個git賬號?9. 發(fā)現(xiàn)了多個名稱為[spring_web]的片段。相對順序不合法10. android - 使用vue.js進行原生開發(fā)如何進行Class綁定
