php-dataset/bin/dataset-info

31 lines
746 B
Plaintext
Raw Normal View History

2022-10-30 17:38:43 +00:00
#!/usr/bin/env php
<?php
foreach ([
2022-10-30 22:21:53 +00:00
__DIR__."/..",
2022-10-30 17:38:43 +00:00
__DIR__."/../vendor",
2022-10-30 22:21:53 +00:00
__DIR__."/../../..",
2022-10-30 22:02:14 +00:00
__DIR__."/vendor",
2022-10-30 17:38:43 +00:00
] as $dir) {
if (file_exists($dir."/autoload.php")) {
2022-10-30 22:02:14 +00:00
define("COMPOSER_VENDOR_PATH", $dir);
2022-10-30 17:38:43 +00:00
require_once $dir."/autoload.php";
}
}
$datasetManager = new NoccyLabs\Dataset\DatasetManager();
$datasets = $datasetManager->getAvailableDatasets();
foreach ($datasets as $dataset) {
2022-10-30 22:02:14 +00:00
echo $dataset->getIdentifier()." (".$dataset->getVersion().")\n";
$reader = $dataset->open();
$rows = 0;
$headers = null;
foreach ($reader as $row) {
if (!$headers) $headers = array_keys($row);
$rows++;
}
2022-10-30 23:42:29 +00:00
echo " # ".$rows." rows\n - ".join("\n - ",$headers)."\n";
2022-10-30 17:38:43 +00:00
}