Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You seem to struggle with the fact that too many files are open at once. You seem to have figured out how to handle the rest of the processing (i.e. sorting the files based on the unique IDs and accessing the values contained in a single <code>.dat</code> file), so i'll just focus on this issue</p> <p>When dealing with multiple sources, a common trick is to remember that you don't need to have all the values at once to compute the average. All you need is the sum and the number of values you have added.</p> <p>I'm not familiar with awk syntax, so i'll write in pseudo-code. </p> <ol> <li>Create a table <code>sum</code> matching your data structure. Let's say <code>sum[x][y]</code> holds the value at column <code>x</code> and line <code>y</code>. The table is initially filled with zeroes.</li> <li>Set a counter <code>n = 0</code></li> <li>Open the first file. I'll skip the processing part you seem to have handled, so say <code>data</code> contains the values you've extracted. The access is similar to the one described for <code>sum</code>.</li> <li>Add the values to your <code>sum</code> table : <code>sum[x][y] += data[x][y]</code> for every <code>x</code> and <code>y</code> value</li> <li>Close the file.</li> <li>Increment the counter : <code>n += 1</code></li> <li>Repeat steps 3 to 6 until you've processed all files</li> <li>Compute the average : <code>sum[x][y] = sum[x][y] / n</code>, for every <code>x</code> and <code>y</code> values</li> <li>You got it! <code>sum</code> now contains the average youre looking for.</li> </ol> <p>This algorithm handles any number of files and only one file is open at any given time.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload