Extracting variables from data printed to screen : <p>I am working on older code, oldCode.py Basically it prints to screen some data, like the sales of items 1,2 and 3.</p>

<p>print '1 500'
   print '2 842'
   print '3 734'</p>

<p>I want to extract this data for further processing.  I know I can stop python from printing this information to the screen, and make it write the information to some file output.dat by writing</p>

<pre><code>python oldCode.py &gt;&gt; output.dat
</code></pre>

<p>However, in the first place how do I even extract the data to process from output.dat when that isn't defined in the script in the first place? And I have to write the results of my processing step to the same output file. Short of rewriting the entire code (final option), how will I be able to do this?</p>
