function getData()
{
    $lengths = array();
    $cands = array();
    $mean = 0;
    foreach (range(1, 100000) as $j) {
        $ballot_set_name = 'ballot_' . sprintf("%07d", $j);
        $dir = substr($ballot_set_name, -3);
        $filepath = 'sim_ballots_uneven/' . $dir . '/' . $ballot_set_name . '.json';
        print "working on {$filepath}\n";
        checkIsFile($filepath);
        $ballots = json_decode(file_get_contents($filepath), 1);
        foreach ($ballots as $bal) {
            $lengths[] = count($bal);
            foreach ($bal as $vote) {
                if (!isset($cands[$vote])) {
                    $cands[$vote] = 0;
                }
                $cands[$vote] += 1;
            }
        }
        if (0 == $j % 10000) {
            $sum = array_sum($lengths);
            $mean = $sum / count($lengths);
            $sd = sd($lengths);
        }
        if ($mean) {
            print "MEAN IS " . $mean . "\n";
            print "STANDARD DEVIATION IS " . $sd . "\n";
        }
    }
    $max_votes = max($cands);
    $min_votes = min($cands);
    $results = array();
    $results['seats_on_slate'] = $seats;
    $results['ballot_sets_count'] = 100000;
    $results['ballot_length_average'] = $mean;
    $results['ballot_length_standard_deviation'] = $sd;
    $results['max_candidate_votes'] = $max_votes;
    $results['min_candidate_votes'] = $min_votes;
    return $results;
}
<?php

$PRINT = 0;
$start = microtime(1);
$iters = 100000;
$seats = 8;
foreach (range(0, $iters) as $j) {
    $ballot_set_name = 'ballot_' . sprintf("%07d", $j);
    $dir = substr($ballot_set_name, -3);
    $filepath = 'sim_ballots_uneven/' . $dir . '/' . $ballot_set_name . '.json';
    print "working on {$filepath}\n";
    checkIsFile($filepath);
    $ballots = json_decode(file_get_contents($filepath), 1);
    $ballots = evenBallotLength($ballots);
    $dir_path = '8seats_uneven/' . $dir;
    if (!is_dir($dir_path)) {
        mkdir($dir_path);
    }
    $result_path = $dir_path . '/' . $ballot_set_name . '.json';
    if (is_file($result_path)) {
        continue;
    }
    //check out
    file_put_contents($result_path, '-');
    $result = array();
    $result['condorcet'] = findCondorcet($filepath);
    $result['approv'] = findApproval($ballots, $seats);
    $result['borda'] = findBorda($ballots, $seats);
    $result['stv'] = findStv($ballots, $seats);
    $result_json = json_encode($result);
    file_put_contents($result_path, $result_json);