Popular recipes tagged "meta:requires=fileinput" but not "text" and "matplotlib"http://code.activestate.com/recipes/tags/meta:requires=fileinput-text-matplotlib/2006-10-07T20:55:12-07:00ActiveState Code Recipesexpand_tabs.py - expand tabs in files in-place (Python)
2006-10-07T20:55:12-07:00Ori Peleghttp://code.activestate.com/recipes/users/2056315/http://code.activestate.com/recipes/498179-expand_tabspy-expand-tabs-in-files-in-place/
<p style="color: grey">
Python
recipe 498179
by <a href="/recipes/users/2056315/">Ori Peleg</a>
(<a href="/recipes/tags/programs/">programs</a>).
Revision 2.
</p>
<p>expand_tabs.py - Similar to Unix's expand(1) command, but can edit the files in-place.</p>
Sort a file (Python)
2005-09-28T15:34:55-07:00Phil Robarehttp://code.activestate.com/recipes/users/2608288/http://code.activestate.com/recipes/440612-sort-a-file/
<p style="color: grey">
Python
recipe 440612
by <a href="/recipes/users/2608288/">Phil Robare</a>
(<a href="/recipes/tags/files/">files</a>).
</p>
<p>A simple (4 lines) recipe that will sort a file named on the command line and write the sorted lines to standard output.</p>
sed/awk : Python script to rename subdirectories of a directory tree, replace strings in files (Python)
2005-07-05T12:33:51-07:00Bibha Tripathihttp://code.activestate.com/recipes/users/2437311/http://code.activestate.com/recipes/435904-sedawk-python-script-to-rename-subdirectories-of-a/
<p style="color: grey">
Python
recipe 435904
by <a href="/recipes/users/2437311/">Bibha Tripathi</a>
(<a href="/recipes/tags/files/">files</a>).
</p>
<p>I needed to write a sed/awk Python equivalent for walking into a directory tree and renaming certain subdirectories, while also looking into all xml files on the way and replacing/modifying certain strings in those files.</p>
<p>It would be nicer if someone could suggest an enhanced re.sub(regex, replacement, subject) where I could replace all strings of a certain pattern with other strings of a certain pattern i.e. the second argument in re.sub namely 'replacement' would then be a regular expression and would be a different string for each different string in 'subject' that matches with the pattern 'regex'. For example 'arthinternational-d' would be replaced by 'arthinternational-r', 'arthfmt-d' would be replaced by 'arthfmt-r' but 'a-d' would remain unmodified.</p>
foreach.py - Execute a python function for a selected set of files. (Python)
2004-08-19T17:12:33-07:00lonetwinhttp://code.activestate.com/recipes/users/1951998/http://code.activestate.com/recipes/300411-foreachpy-execute-a-python-function-for-a-selected/
<p style="color: grey">
Python
recipe 300411
by <a href="/recipes/users/1951998/">lonetwin</a>
.
Revision 3.
</p>
<p>equivalent to doing
$ find -name "*ext" -exec (some python function) {} ';'</p>
Indexing into XML (Python)
2002-10-08T05:38:27-07:00Dave Pawsonhttp://code.activestate.com/recipes/users/127209/http://code.activestate.com/recipes/155582-indexing-into-xml/
<p style="color: grey">
Python
recipe 155582
by <a href="/recipes/users/127209/">Dave Pawson</a>
.
</p>
<p>Build an index into a directory of xml files.
Search the index. Based around the indexing code
from Alex Martelli, linux magazine, July 2002.</p>