Blobject#

class Blobject(source=None, name=None, filename=None, blob=None)[source]#

Bases: object

A wrapper for a binary file – rarely used directly.

So named because it’s an object representing a blob.

“source” is a specification of where to get the data from. It can be anything supported by Blobject.load() which are (a) a filename, which will get loaded, or (b) a io.BytesIO which will get dumped into this instance

Alternatively, can specify blob which is a binary string that gets stored directly in the blob attribute

Methods

load(source=None)[source]#

This function loads the spreadsheet from a file or object. If no input argument is supplied, then it will read self.bytes, assuming it exists.

save(filename=None)[source]#

This function writes the spreadsheet to a file on disk.

tofile(output=True)[source]#

Return a file-like object with the contents of the file.

This can then be used to open the workbook from memory without writing anything to disk e.g.

  • book = openpyxl.load_workbook(self.tofile())

  • book = xlrd.open_workbook(file_contents=self.tofile().read())

freshbytes()[source]#

Refresh the bytes object to accept new data