def transcode_to_stream(input_filename, date_format=None):
tmp = tempfile.TemporaryFile()<EOL>for entry in open_json_or_csv_somehow(input_filename,<EOL>date_format=date_format):<EOL><INDENT>tmp.write(json.dumps(entry, ensure_ascii=False).encode('<STR_LIT:utf-8>'))<EOL>tmp.write(b'<STR_LIT:\n>')<EOL><DEDENT>tmp.seek(<NUM_LIT:0>)<EOL>return tmp<EOL>
Read a JSON or CSV file and convert it into a JSON stream, which will
be saved in an anonymous temp file.