I'm trying to solve reading a zipfile from stdin in python, but I keep getting issues. What I want is to be able to run cat test.xlsx | python3 test.py and create a valid zipfile.ZipFile object without first writing a temporary file if possible.
My initial approach was this, but ZipFile complained the file is not seekable,
import sys
import zipfile
zipfile.ZipFile(sys.stdin)
so I changed it around, but now it complains that this is not a valid zip file:
import io
import sys
import zipfile
zipfile.ZipFile(io.StringIO(sys.stdin.read()))
Can this be solved without writing the zip to a temporary file?
in | ziphandlerwhere in comes from aerc (reading an xslx attachment in the pager).