Popular recipes tagged "text" and "binary"http://code.activestate.com/recipes/tags/text+binary/popular/2010-04-18T17:18:50-07:00ActiveState Code RecipesFile read/write routines (Python)
2010-04-18T17:18:50-07:00Denis Barmenkovhttp://code.activestate.com/recipes/users/57155/http://code.activestate.com/recipes/577199-file-readwrite-routines/
<p style="color: grey">
Python
recipe 577199
by <a href="/recipes/users/57155/">Denis Barmenkov</a>
(<a href="/recipes/tags/binary/">binary</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/read/">read</a>, <a href="/recipes/tags/text/">text</a>, <a href="/recipes/tags/write/">write</a>).
Revision 2.
</p>
<p>For small dirty hacks in Perl has a module File::Slurp.
I wrote two simple functions when I moving from Perl to Python - one for reading files and second for writing files. Valuable data is list of lines or blob (additionally specified argument binmode=1).</p>
Sorting big files the Python 2.6 way (Python)
2009-05-30T21:51:09-07:00Gabriel Genellinahttp://code.activestate.com/recipes/users/924636/http://code.activestate.com/recipes/576755-sorting-big-files-the-python-26-way/
<p style="color: grey">
Python
recipe 576755
by <a href="/recipes/users/924636/">Gabriel Genellina</a>
(<a href="/recipes/tags/binary/">binary</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/sort/">sort</a>, <a href="/recipes/tags/sorting/">sorting</a>, <a href="/recipes/tags/text/">text</a>).
Revision 3.
</p>
<p>This is just a rewrite of <a href="http://code.activestate.com/recipes/466302/">Recipe 466302</a> "Sorting big files the Python 2.4 way", taking advantage of heapq.merge, context managers, and other niceties of newer Python versions. It can be used to sort very large files (millions of records) in Python. No record termination character is required, hence a record may contain embedded binary data, newlines, etc. You can specify how many temporary files to use and where they are located.</p>