Hi,<br><br><div class="gmail_quote">On 9 May 2012 20:26, Joel Goldstick <span dir="ltr">&lt;<a href="mailto:joel.goldstick@gmail.com" target="_blank">joel.goldstick@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
import os<br>
def pre_process():<br>
    if os.path.isfile(&#39;revelex.csv&#39;):<br>
        os.rename(&#39;revelex.csv&#39;, &#39;revelex.tmp&#39;)<br>
        print &quot;Renamed ok&quot;<br>
    else:<br>
        print &quot;Exiting, no revelex.csv file available&quot;<br>
        exit()<br>
    out_file = open(&#39;revelex.csv&#39;, &#39;w&#39;)<br>
    # etc.<br>
<br>
if __name__ == &#39;__main__&#39;:<br>
    pre_process()<br>
<br>
<br>
When I run the code above it works file if run from the file.  But<br>
when I import it and run it from another file it renames the file but<br>
then prints &quot;Exiting, no revelex.csv file available&quot;<br></blockquote><br>
</div><br>Can you post where/how you call this from another file? Anyway, it sounds like the pre_process() routine is being called twice, somehow.  On the first call the file is renamed.  Then on the second call, of course the file is not there anymore (as it&#39;s been renamed) and thus it prints the &quot;Exiting&quot; message.  <br>
<br>Best,<br><br>Walter<br>