Commit f8646765 authored by Fabrice Gangler's avatar Fabrice Gangler 🎨
Browse files

FIX: update SILL import script (update data source URL)

parent f017dfba
Pipeline #20876 passed with stage
in 10 minutes and 48 seconds
......@@ -10,28 +10,34 @@ $tagIds[2021] = 474; // Tag "SILL-2021" --> https://comptoir-du-libre.org/tags/
# data source
$url = "https://raw.githubusercontent.com/DISIC/sill/master/2020/sill-2020.csv";
$url = "https://git.sr.ht/~etalab/sill/blob/master/sill.csv";
# Legacy data source
# $url = "https://raw.githubusercontent.com/DISIC/sill/master/2020/sill-2020.csv";
/////////////////////////////////////////////////////////////////////////
// get the source file
$fileName = 'SILL_2020.csv';
$dataSrc = file_get_contents($url);
file_put_contents($fileName, $dataSrc); /* [0] => ID
[1] => nom
[2] => fonction
[3] => annees
[4] => statut
[5] => parent
[6] => public
[7] => support
[8] => similaire-a
[9] => wikidata
[10] => comptoir-du-libre
[11] => licence */
file_put_contents($fileName, $dataSrc); /* [0] => ID
[1] => nom
[2] => fonction
[3] => annees
[4] => statut
[5] => parent
[6] => public
[7] => support
[8] => similaire-a
[9] => wikidata
[10] => comptoir-du-libre
[11] => licence
... */
// column numbers of the csv file
$numberOfFileFields = 17;
$numberOfFileFields = 19;
$colId=0;
$colName=1;
$colYears = 3;
$colWikidata = 9;
$colComptoir = 10;
......@@ -43,7 +49,7 @@ $noIds = [];
if (($handle = fopen($fileName, "r")) !== false) {
while (($data = fgetcsv($handle, 1000, ",")) !== false) {
$num = count($data);
echo "\nline $row:";
echo "\nline $row:"; // DEBUG print_r($data); exit();
// check the number of fields in the line
if ($num !== $numberOfFileFields) {
......@@ -65,6 +71,8 @@ if (($handle = fopen($fileName, "r")) !== false) {
// line processing
if ($row !== 1 && !empty($data[$colYears]) && !empty($data[$colComptoir])) {
$softwareId = $data[$colId];
$softwareName = $data[$colName];
$idComptoir = $data[$colComptoir];
$idWikidata = $data[$colWikidata];
$lineYears = explode(';', $data[$colYears]);
......@@ -75,7 +83,11 @@ if (($handle = fopen($fileName, "r")) !== false) {
$years[$year][$idComptoir] = $idWikidata;
}
}
echo " idSILL->$softwareId / idComptoir->$idComptoir / idWikidata->$idWikidata -----> $softwareName";
} else {
$softwareId = $data[$colId];
$softwareName = $data[$colName];
echo " -----> $softwareName";
$noIds[$row] = $data;
}
$row++;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment