static function table_info($name)
 {
     $sname = explode(".", $name);
     if (count($sname) == 2) {
         $result = scraperwiki::sqlitecommand("execute", "PRAGMA " . $sname[0] . ".table_info(`" . $sname[1] . "`)");
     } else {
         $result = scraperwiki::sqlitecommand("execute", "PRAGMA table_info(`" . $name . "`)");
     }
     $res = array();
     foreach ($result->data as $i => $row) {
         array_push($res, array_combine($result->keys, $row));
     }
     return $res;
 }
$key = array('year', 'month', 'day', 'hour');
foreach ($data as $row) {
    $newData = array();
    foreach ($row as $k => $value) {
        $newData[$k] = $value;
    }
    scraperwiki::save_sqlite($key, $data);
}
#$sql="SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;";
#$x = scraperwiki::sqlitecommand("execute", $sql);
#print_r($x);
$sql = "SELECT count(*) as number FROM swdata;";
$x = scraperwiki::sqlitecommand("execute", $sql);
echo "rows:" . $x->data[0][0] . "<br/>\n";
$sql = "SELECT COUNT(*) as n, MAX(direction) as d FROM swdata GROUP BY direction;";
$x = scraperwiki::sqlitecommand("execute", $sql);
$x = $x->data;
echo "totals by direction:";
foreach ($x as $row) {
    foreach ($row as $cell) {
        echo $cell . " ";
    }
    echo ",";
}
echo "<br/>\n";
$sql = "SELECT COUNT(*) as n, MAX(hour) as h FROM swdata WHERE direction='N' GROUP BY hour;";
$x = scraperwiki::sqliteexecute($sql);
$x = $x->data;
echo "N totals by hour:";
foreach ($x as $row) {
    foreach ($row as $cell) {