#!/usr/bin/env php
<?php

foreach ([
    __DIR__."/..",
    __DIR__."/../vendor",
    __DIR__."/../../..",
    __DIR__."/vendor",
] as $dir) {
    if (file_exists($dir."/autoload.php")) {
        define("COMPOSER_VENDOR_PATH", $dir);
        require_once $dir."/autoload.php";
    }
}

$datasetManager = new NoccyLabs\Dataset\DatasetManager();

$datasets = $datasetManager->getAvailableDatasets();

foreach ($datasets as $dataset) {
    echo $dataset->getIdentifier()." (".$dataset->getVersion().")\n";
    $reader = $dataset->open();
    $rows = 0;
    $headers = null;
    foreach ($reader as $row) {
        if (!$headers) $headers = array_keys($row);
        $rows++;
    }
    echo "  # ".$rows." rows\n  - ".join("\n  - ",$headers)."\n";
}