There is an excel spreadsheet that lives on an endpoint, where when pinged by a get request will return an excel speadsheet .xlsx. It works on postman, however predictably returns a binary that it cannot understand. How can i go about consuming this file as a pandas dataframe (or similar), parse a row, then return a JSON using python flask?
Asked
Active
Viewed 243 times
1 Answers
0
For Python, you may download the spreadsheet file to a temporary directory using a library such as urllib.request
.
import urllib.request
urllib.request.urlretrieve(SPREADSHEET_URL, SAVE_AS_NAME.xlsx)
Once the file has been downloaded, simply load the spreadsheet file into your library of choice. For example, Pandas:
import pandas as pd
df = pd.read_excel(SAVE_AS_NAME)
...
# The first row all columns
df.loc[0,:]

ProAdam
- 51
- 5