mirror of
https://github.com/limosek/zaf-plugins.git
synced 2025-11-01 01:57:38 +01:00
Added CSV plugin
This commit is contained in:
27
csv/get_fields.php
Normal file
27
csv/get_fields.php
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/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();
|
||||
|
||||
$last=end($header);
|
||||
foreach ($header as $num=>$column) {
|
||||
if (!array_key_exists($num,$range)) continue;
|
||||
json_row();
|
||||
json_column("FIELD","$column",true);
|
||||
json_row_end($last==$column);
|
||||
}
|
||||
|
||||
json_end();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user