I want to access an excel file in a cloud function which is present in the google cloud storage, what modules do I need to use?
You can consider trying Cloud Dataprep for reading your Excel data.
It natively supports Excel workbooks, though they need to be uploaded to Dataprep, versus being read from GCS. If you are trying to parse and clean Excel workbook data for further analysis, Dataprep may be more convenient, and it happens to use Dataflow for processing underneath.
References:
All interesting information, and … I am Not sure if this answers the question.?
GCS exposes a REST API. You can invoke the REST API to retrieve the XSLX file (or any file) in a bucket in GCS. Check the documentation on GCS for more details.
BTW, this is not really an Apigee question.
Hey, when i do read excel, i keep running into an error:
vbnetCopyEditImportError: No module named expat; use SimpleXMLTreeBuilder instead
ImportError: Missing optional dependency 'openpyxl'. Use pip or conda to install openpyxl.
Im working on a Google Cloud Function (Python 3.11-tried on 3.10 also same problem) that downloads .xlsx reports from Google Drive using the Google Drive API. It uses pandas.read_excel() to parse the Excel content:
pythonCopyEditfh = io.BytesIO()
request = drive_service.files().get_media(fileId=file_id)
downloader = MediaIoBaseDownload(fh, request)
while not done:
_, done = downloader.next_chunk()
fh.seek(0)
df = pd.read_excel(fh, engine="openpyxl")
- openpyxl is included in requirements.txt and confirmed to install correctly (even added test imports)
not an Apigee question. I suggest that you ask a new question and direct it to the appropriate forum/space.
Good luck.