I have a type bytes file loaded in memory. How can I create identical files, as-if I was loading from my disk with open?
Consider the following:
type(downloaded_bytes) # bytes
f = io.StringIO(downloaded_bytes.decode('utf-8')).readlines()
f2 = open(r"file.log", "r").readlines()
f == f2 # false
The large thing I noticed inspecting the files is that retrieving the file as bytes has replaced linebreaks. For example, in f2, a line reads like this:
'Initializing error logging... Success\n',
While in the bytes derived file, f, the same line reads:
'Initializing error logging... Success\r\n',
In other areas, \n (the expected line break), is replaced by \r in the bytes file.
How might I force f to be exactly like f2 here?