Here's a function I've just hobbled together. It's only a start. Try
enabling it on a page then run the markup below it.
<?php
function BOLTFcsv($args, $zone) {
global $BOLTcsvData;
$content = trim(BOLTloadpage($args['page']));
$rows = explode("\n", $content);
$content = substr($content, strpos($content, "\n") + 1);
$headers = explode(',', $rows[0]);
foreach ($rows as $i => $ii) {
if ($i == 0) continue;
$cols = explode(',', $ii);
foreach ($cols as $c => $cc) $data[$i][$c] = $cc;
}
if (isset($args['row']) && isset($args['col'])) return
$data[$args['row']][$args['col'] - 1];
if (isset($args['row'])) {
if (isset($args['fmt'])) {
$out = $args['fmt'];
foreach ($headers as $h => $hh) {
$out = str_replace("{+$hh}",
$data[$args['row']][$h], $out);
}
return $out;
}
return $rows[$args['row']];
}
return '[t border=1][r][h]' . str_replace(',', '[h]', $rows[0]) .
'[r][c]' . str_replace(Array(',', "\n"), Array('[c]', "[r][c]"),
$content) . '[t]';
}
----
test.csv:
[(csv page=test.csv.1)]
----
[(csv page=test.csv.1 row=2 fmt='Name: {+name}, Age: {+age}, State: {+state}')]
----
[(csv page=test.csv.1 row=2 col=2)]
----
test.csv.1
name,age,state
Bob,23,CA
Mark,32,OK
John,23,CA
Dave,24,NM
Rich,37,TX
It's only a start and needs more functionality. Such as a command for
saving content to the CSV. Working with other directories, etc. But
I'm still waiting on feedback on the syntax, before going too much
further.
Cheers,
Dan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"BoltWire" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/boltwire?hl=en
-~----------~----~----~----~------~----~------~--~---