コード例 #1
0
    foreach ($row as $key => $value) {
        $row[$key] = preg_replace("/\"/", "\"\"", $value);
    }
    fprintf($handle, "\"%s\"\n", implode("\",\"", $row));
}
/*********************************************************************/
$filter = $argv[1];
$in = $argv[2];
$out = $argv[3];
// Process the input file
if (!file_exists($in)) {
    print_usage_and_exit("File {$in} not found");
}
$csv = read_input($in, isset($argv[5]) ? $argv[5] : ',');
// Filter the CSV data for conversion
if (!@(include $filter)) {
    print_usage_and_exit("Could not include filter script {$in}");
}
$conf = formatter_filter($csv);
$conf["start_at"] = isset($conf["start_at"]) ? $conf["start_at"] : 1;
$conf["id"] = isset($conf["id"]) ? $conf["id"] : 0;
$conf["rows"] = isset($conf["rows"]) ? $conf['rows'] : array();
$csv = formatter($csv, $conf);
// Write the output
$handle = fopen($out, 'w');
if (!$handle) {
    // print_error_and_exit('Could not create output file');
}
write_output($handle, $csv);
fclose($handle);
print "Successfully format all test cases\n";
コード例 #2
0
ファイル: if.php プロジェクト: nomad-mystic/CIS195PHP
function output_letter_grade($score)
{
    if ($score >= 90) {
        $grade = 'A';
    } else {
        if ($score >= 80) {
            $grade = 'B';
        } else {
            if ($score >= 70) {
                $grade = 'C';
            } else {
                if ($score >= 60) {
                    $grade = 'D';
                } else {
                    $grade = 'F';
                }
            }
        }
    }
    write_output('' . "Students grade is {$grade}" . '');
}
コード例 #3
0
$csv = read_input($in, isset($argv[5]) ? $argv[5] : ',');
if ($mode == MODE_CSV) {
    print_r($csv);
    exit(1);
}
// Filter the CSV data for conversion
if (!@(include $filter)) {
    print_usage_and_exit("Could not include filter script {$in}");
}
if (!function_exists('custom_filter')) {
    print_error_and_exit("Filter function 'custom_filter' not " . "defined in filter script");
}
$cases = filter_csv_input($csv);
if ($mode == MODE_CASES) {
    print_r($cases);
    exit(1);
}
// Generate a section tree
$sections = build_tree($cases);
if ($mode == MODE_TREE) {
    print_r($sections);
    exit(1);
}
// Write the output
$handle = fopen($out, 'w');
if (!$handle) {
    print_error_and_exit('Could not create output file');
}
write_output($handle, $sections);
fclose($handle);
print "Successfully converted {$section_count} sections and {$case_count} cases\n";