[Tutor] Syntax for Simplest Way to Execute One Python Program Over 1000's of Datasets

Walter Prins wprins at gmail.com
Thu Jun 9 22:07:34 CEST 2011


On 9 June 2011 20:49, B G <compbiocancerresearcher at gmail.com> wrote:

> I'm trying to analyze thousands of different cancer datasets and run the
> same python program on them.  I use Windows XP, Python 2.7 and the IDLE
> interpreter.  I already have the input files in a directory and I want to
> learn the syntax for the quickest way to execute the program over all these
> datasets.
>
> As an example,for the sample python program below, I don't want to have to
> go into the python program each time and change filename and countfile.  A
> computer could do this much quicker than I ever could.  Thanks in advance!
>

OK, so make a function of the current program logic for a single filename,
and make the base filename a parameter to that function.  Then write another
function (or main program) that iterates over your directory tree and calls
the processing function for each input file.  See documentation for module
os, specifically os.walk().  (See here:
http://docs.python.org/library/os.html )

If that doesn't get you going then post back again.

Walter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110609/39debe7d/attachment.html>


More information about the Tutor mailing list