Python Pandas: Input Authorized Excel File into Pandas

I am trying to get data from .xlsb file in an authorized website. But it comes out with error message: 'HTTP Error 401: Unauthorized'. What should I do to authorize so that the data comes out in pandas table in Python? Here the code that I tried so far:

supplier_list_xlsb = pd.read_excel('https://..../3026744.xlsb', sheet_name = 'xxxxxx',engine = 'pyxlsb')

Upvotes: 0

Views: 650

Answers (2)

I already got the answer. I need to use NTLM authentication (instead of basic) to download the file and use the downloaded file into Pandas to get the table. Here is the code:

import requests
from requests_ntlm3 import HttpNtlmAuth

auth=HttpNtlmAuth('username','password')
myfile = requests.get("https://..../3026744.xlsb", auth=auth)

open('C:/Users/Desktop/test/Supplier.xlsb', 'wb').write(myfile.content)

supplier_list_xlsb = pd.read_excel('C:/Users/Desktop/test/Supplier.xlsb', sheet_name = 'xxxxxx',engine = 'pyxlsb')

Upvotes: 0

Rav Singh Sandhu
Rav Singh Sandhu

Reputation: 62

Clear your browser's cache may be that will help resolve this issue.Are you sure website is authorized to access?

Upvotes: 1

Related Questions