Using openpyxl to read file from memory

In the docs for load_workbook it says:

#:param filename: the path to open or a file-like object

..so it was capable of it all the time. It reads a path or takes a file-like object.
I only had to convert my file-like object returned by urlopen, to a bytestream with:

from io import BytesIO
wb = load_workbook(filename=BytesIO(input_excel.read()))

and I can read every piece of data in my Google-spreadsheet.

Leave a Comment