I am downloading files in a cloud environment whereby I am given the file as a type bytes
.
The formatting on the bytes file conflicts with my processing and thus I would like the bytes file to conform to the way Python handles this basic function:
f = open(r"file.log", "r").readlines()
Is there a way that I can massage a type(bytes)
object to look and behave like the above f
?
Edit:
The bytes file is NOT saved to disk. It is stored in memory. It looks like
type(downloaded_bytes) # bytes
This fails:
f = open(downloaded_bytes, "rb").readlines()
Edit 2:
These are not equivalent:
f = io.BytesIO(downloaded_bytes).readlines()
f2 = open(r"file.log", "r").readlines()
f == f2 # false