What I need is a Python 3 function (or whatever) that would take a text stream (like sys.stdin
or like that returned by open(file_name, "rt")
) and return a text stream to be consumed by some other function but remove all the spaces, replace all tabs with commas and convert all the letters to lowercase on the fly (the "lazy" way) as the data is read by the consumer code.
I assume there is a reasonably easy way to do this in Python 3 like something similar to list comprehensions but don't know what exactly might it be so far.
(e.replace(" ",'').replace("\t",',').lower() for e in file)
generator might work. It does things the "lazy" way – Pierrepierrepont