using walk function in python
<p>I am dealing with a folder hierarchy like the following:</p>

<pre><code>c:/users/rox/halogen/iodine/(some .txt files)
c:/users/rox/halogen/chlorine/(some .txt files)
c:/users/rox/inert/helium/(some .txt files)
c:/users/rox/inert/argon/(some .txt files)
</code></pre>

<p>now I was iterating through out the folder by using <code>os.walk</code> and processing the files.<br>
But the problem is if I want to generate analysis output to the folder 'halogen' after analyzing all sub-folders under halogen then what should I do...
I was using:</p>

<pre><code>for root,dirs,files in os.walk(path,'*.txt):
    .....
    .......[processing file]
    out.write(.....)    # writing output in the folder which we are analyzing
</code></pre>

<p>but how to write the output to a folder that lies two-step back(i.e halogen or inert)..</p>
