Python Error : read excel file(included xlsx, ...)

 An internal security tool caused a problem because xlsx was locked into a security program.
In conclusion, the following method was used, but it could not be solved.

error handling step...

code : occurred openpyxl error  

< zipfile.BadZipFile: File is not a zip file >


import openpyxl

 

if __name__ == "__main__" :

    wb = openpyxl.load_workbook("contents.xlsx")

    print(f"{wb}")

error

zipfile.BadZipFile: File is not a zip file


The following methods were used to solve this problem caused by in-house security tools.


step 1. encoding error 

< UnicodeDecodeError: 'cp949' codec can't decode byte 0xf0 in position 20: illegal multibyte sequence >


import openpyxl

import xlrd #add

if __name__ == "__main__" :

    file = open("contents.xlsx","r")

    wb = xlrd.open_workbook(file_contents=file.read()) #add

    print(f"wb")

 

error

wb = xlrd.open_workbook(file_contents=file.read())

UnicodeDecodeError: 'cp949' codec can't decode byte 0xf0 in position 20: illegal multibyte sequence



step 2. encoding error : add utf-8

< TypeError: an integer is required (got type str) >


import openpyxl

import xlrd

if __name__ == "__main__" :

    file = open("contents.xlsx","r", "utf-8")

    wb = xlrd.open_workbook(file_contents=file.read())

    print(f"wb")

 

error

file = open("contents.xlsx","r","utf-8")

TypeError: an integer is required (got type str)

must be specified Encoding type like "utf-8" as "python2 -> python3".



step 3. ???
< TypeError: an integer is required (got type str) >

import openpyxl

import xlrd

if __name__ == "__main__" :

    file = open("contents.xlsx","r", encoding="utf-8")

    wb = xlrd.open_workbook(file_contents=file.read())

    print(f"wb")

 

error

file = open("contents.xlsx","r", encoding="utf-8")

TypeError: an integer is required (got type str)

"utf-8-> encoding="utf-8"



It still hasn't been resolved.
Does anyone know how to read the Excel file that was locked due to the security tool?


#python error #read excel #openpyxl #zipfile.BadZipFile #encoding error

No comments:

Post a Comment

알뜰폰 삼성페이 교통카드 '한도 초과' 오류(등록 불가 오류) 해결방법

sk7mobile 알뜰폰 삼성페이 교통카드 등록 시, 한도 초과 문제 해결방법 skt usim 해킹 사건으로 인해 sk7mobile 알뜰폰을 사용하는 저도 usim을 바꾸고 나니 삼성페이 교통카드가 등록이 안되더라구요...  삼성페이 교통카드 기능 은...