Revision: 7134
http://sourceforge.net/p/astlinux/code/7134
Author: abelbeck
Date: 2015-07-03 15:55:35 +0000 (Fri, 03 Jul 2015)
Log Message:
-----------
parse-csv, new command, parse a comma-seperated-value string like an Asterisk CDR line and output each value followed by a new-line. Fields may be quoted with double-quotes and a quoted quote is encoded as two double-quotes as per RFC specs.
Added Paths:
-----------
branches/1.0/project/astlinux/target_skeleton/usr/bin/parse-csv
Added: branches/1.0/project/astlinux/target_skeleton/usr/bin/parse-csv
===================================================================
--- branches/1.0/project/astlinux/target_skeleton/usr/bin/parse-csv (rev 0)
+++ branches/1.0/project/astlinux/target_skeleton/usr/bin/parse-csv 2015-07-03 15:55:35 UTC (rev 7134)
@@ -0,0 +1,21 @@
+#!/usr/bin/php -qC
+<?php
+if (! isset($argv)) {
+ $argv = $_SERVER['argv'];
+}
+
+$str = $argv[1];
+
+if ($str == '') {
+ echo "Usage: parse-csv csv_string\n";
+ exit(1);
+}
+
+$csv = str_getcsv($str, ',', '"', '""');
+
+foreach ($csv as $line) {
+ echo "$line\n";
+}
+
+exit(0);
+?>
Property changes on: branches/1.0/project/astlinux/target_skeleton/usr/bin/parse-csv
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|