<?php

require 'inc.php';
require 'curieous/rdfbuilder.class.php';
$datasets = json_decode(file_get_contents('datasets_with_sample_series.json'), 1);
$rdf = new RdfBuilder();
foreach ($datasets as $dataset => $serieskey) {
    $url = 'http://sdw.ecb.europa.eu/quickviewexport.do?trans=&SERIES_KEY=' . $serieskey . '&type=csv';
    //  $url = 'http://sdw.ecb.europa.eu/export.do?SERIES_KEY='.$serieskey.'&exportType=csv';
    $csv = fopen($url, 'r');
    $row = fgetcsv($csv);
    $datasetfield = array_shift(explode(';', $row[0]));
    $datasetName = trim(array_pop(explode(':', $datasetfield)));
    $rdf->thing($dataset)->label($datasetName, 'en');
}
echo $rdf->dump_ntriples();
Esempio n. 2
0
function varify($i)
{
    return preg_replace('/[^0-9a-zA-Z]+/', '_', $i);
}
$vars = array_map('varify', $columnNames);
$Rdf = new RdfBuilder();
register('eum', NS);
register('aiiso', $curieous->uri('aiiso:'));
$Rdf->create_vocabulary('eum', NS, 'EUMIDA Vocabulary', 'http://keithalexander.co.uk/id/me');
$doctoratesDatasetUri = EUMIDA . 'dataset/doctorates-awarded';
$studentsISCED5DatasetUri = EUMIDA . 'dataset/ISCED5-students-enrolled';
$internationStudentsDatasetUri = EUMIDA . 'dataset/international-ISCED5-students-enrolled';
$studentsISCED6DatasetUri = EUMIDA . 'dataset/ISCED-6-students-enrolled';
$isced6InternationalStudentsDatasetUri = EUMIDA . 'dataset/international-ISCED-6-students-enrolled';
$totalStaffDatasetUri = EUMIDA . 'dataset/total-staff';
$Rdf->thing($doctoratesDatasetUri)->a('qb:DataSet')->label('Numbers of Doctorates Awarded by Higher Education Institutions', 'en');
$Rdf->thing($studentsISCED5DatasetUri)->a('qb:DataSet')->label('Numbers of ISCED 5 Students Enrolled in European Higher Education Institutions', 'en');
$Rdf->thing($internationStudentsDatasetUri)->a('qb:DataSet')->label('Numbers of International ISCED 5 Students at European Higher Education Institutions', 'en');
$Rdf->thing($studentsISCED6DatasetUri)->a('qb:DataSet')->label('Numbers of ISCED 6 Students Enrolled in European Higher Education Institutions', 'en');
$Rdf->thing($isced6InternationalStudentsDatasetUri)->a('qb:DataSet')->label('Numbers of International ISCED 6 Students at European Higher Education Institutions', 'en');
$Rdf->thing($totalStaffDatasetUri)->a('qb:DataSet')->label('Numbers of Members of Staff at European Higher Education Institutions', 'en');
foreach (array('eum:numberOfStaff', 'eum:numberOfDoctoratesAwarded', 'eum:numberOfInternationalISCED6Students', 'eum:numberOfISCED6Students', 'eum:numberOfInternationalISCED5Students', 'eum:numberOfISCED5Students') as $curie) {
    $Rdf->get_vocab_builder()->thing(uri($curie))->a('qb:MeasureProperty');
}
while ($line = fgetcsv($file)) {
    foreach ($vars as $n => $name) {
        ${$name} = trim($line[$n]);
    }
    $instUri = EUMIDA . 'institution/' . $EUMIDA_ID;
    $countryUri = EUMIDA . 'country/' . $Country_Code;
    $countryName = $countries[$Country_Code];
    $lastTopic = false;
    $uris = array();
    while ($topic = array_shift($topics)) {
        $label = ucwords(str_replace('-', ' ', $topic));
        $topicUri = NS . 'concepts/' . $topic;
        $uris[] = $topicUri;
        $Topic = $conceptRdf->thing($topicUri)->a('skos:Concept')->label($label, 'en')->has('skos:inScheme')->r(NS . 'conceptscheme/ecb');
        if (!$lastTopic) {
            $Topic->has('skos:topConceptOf')->r(NS . 'conceptscheme/ecb')->object()->a('skos:ConceptScheme')->label('European Central Bank Concepts', 'en')->has('dct:description')->l("Concepts used by the European Central Bank Statistical Warehouse", 'en')->has('skos:hasTopConcept')->r($topicUri);
        } else {
            $Topic->has('skos:broader')->r($lastTopic)->is('skos:narrower')->of($lastTopic);
        }
        $lastTopic = $topicUri;
    }
    return $uris;
}
$filename = $argv[1];
$fh = fopen($filename, 'r');
while ($row = fgetcsv($fh)) {
    set_time_limit(9999999999999);
    if (count($row) > 2) {
        csv_row_to_rdf($row);
    }
}
echo $conceptRdf->dump_ntriples();
foreach ($datasetUris as $uri => $v) {
    $rdf->thing($uri)->a('qb:DataSet')->has('dct:creator')->r('http://institutions.publicdata.eu/#ecb');
    echo $rdf->dump_ntriples();
}
file_put_contents('datasets_with_sample_series.json', json_encode($datasetUris));
echo $dateRdf->dump_ntriples();