MNP01/tex.php
2018-03-18 21:31:48 +01:00

16 lines
545 B
PHP

<?php
$filename = $argv[1];
$input = fopen($argv[1], "r");
$coordinates = fopen(str_replace(".csv", "-c.tex", $filename), "w");
$actions = fopen(str_replace(".csv", "-a.tex", $filename), "w");
fgetcsv($input); // ommit header
while (list($no, $x, $action) = fgetcsv($input)) {
fwrite($coordinates, sprintf("\\coordinate (action-%d) at (%d,0);\n", $no, $x));
fwrite($actions, sprintf("\\draw [%s] (action-%d|-G c1r1.north) -- (action-%d|-G c1r3.south);\n", $action, $no, $no));
}
fclose($input);
fclose($coordinates);
fclose($actions);