'How to process a string as a file to contruct a ZipFile object?
I am currently pulling data from a database with blobs. I retrieve the blob from the database, but I need to parse the text. the ZipFile class takes in files not strings, so what would be a good way to solve this?
import zipfile
data= request.files["file"].read() #this is just binary data
zipfile.ZipFile(data)
Solution 1:[1]
use io.BytesIO or io.StringIO
essentially u just need file-like interface
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | hipjoy |