2017-01-27 16:05:02 +01:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once(__DIR__."/functions.inc.php");
|
|
|
|
|
|
|
|
$csv=getenv("csv");
|
|
|
|
$range=parse_colnum(getenv("columns"));
|
|
|
|
$rangef=array_flip($range);
|
|
|
|
$delim=getenv("delimiter");
|
|
|
|
|
|
|
|
$c=fopen($csv,"r");
|
|
|
|
$header=fgetcsv($c,false,$delim);
|
|
|
|
fclose($c);
|
|
|
|
|
|
|
|
json_init();
|
|
|
|
|
2017-01-30 10:31:37 +01:00
|
|
|
$last1=end($header);
|
|
|
|
$last2=end($range);
|
|
|
|
|
2017-01-27 16:05:02 +01:00
|
|
|
foreach ($header as $num=>$column) {
|
|
|
|
if (!array_key_exists($num,$range)) continue;
|
|
|
|
json_row();
|
2017-01-30 10:31:37 +01:00
|
|
|
json_column("COLUMN",$num);
|
|
|
|
json_column("NAME",addslashes($column),true);
|
|
|
|
json_row_end($last1==$column||$last2==($num+1));
|
2017-01-27 16:05:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
json_end();
|
|
|
|
|
|
|
|
|