I have a dozen of files that I would like to present to the user as a single read only file like object. I do not want to load them into memory at once, nor merge them in the filesystem. I would like something like a itertools.chain
of mmap.mmap
but present the API of a file like object (i.e. with the file methods like read, etc). Is this possible?
You can use fileinput
module here to read through multiple files.
Lets say for example you want to read two files new.txt
and IQ.txt
.
for line in fileinput.input(["C:\\Users\\Administrator\\Desktop\\new.txt","C:\\Users\\Administrator\\Desktop\\IQ.txt"]):
print line,
In nutshell you provide a list
of files you want to read and do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With