Browse Source

Extract - Extraction des rangs limites, nb de postes offerts, choisis et laissés dispo

Guichen 3 years ago
parent
commit
33c79c3341

+ 42 - 0
_oldFiles/_extractRangLimitesEtNbPostesDispo.php_

@@ -0,0 +1,42 @@
+<?php
+require_once "libs/fnMain.php";
+// Page permettant d'extraire le nombre de postes proposés, choisis, laissés libres, leur rang limite
+
+function main(string $html)
+{
+    global $_SETTINGS;
+
+    $regex = '#norm(\d+)".+\n(\d+)<span>dispo : (\d{1,5})<br>[\s\S]+placé : (\d{1,5})<br>[\s\S]+offre : (\d{1,5})<hr>#U';
+    $matches = [];
+    preg_match_all($regex, $html, $matches, PREG_SET_ORDER);
+    // var_dump($matches);die();
+
+    $specialitySourceDatasetAbrev = getCsvToArrayKeyValue($_SETTINGS["datasetFolder"]."/liste_specialites_abrev.csv");
+    $citySourceDatasetAbrev = getCsvToArrayKeyValue($_SETTINGS["datasetFolder"]."/raphael/liste_villes_abrev_raph.csv");
+    // Génération CSV
+    $strResult = "Session,Spe,CHU,Postes,Offres_Norm,Dispo,Rang_Limite,Offres_CESP<br>";
+
+    foreach ($matches as $match) {
+        // On split l'id du choix en identifiant
+        $cityId = substr($match[1], 1, 2);
+        $speId = substr($match[1], 3, 3);
+
+        // On insère les données
+        $strResult .= "ecn2017,"; // CHANGER LIGNE ICI POUR ANNEE
+        $strResult .= $specialitySourceDatasetAbrev[$speId] . ",";
+        $strResult .= $citySourceDatasetAbrev[$cityId]. ",";
+        $strResult .= $match[4] . ",";
+        $strResult .= $match[5] . ",";
+        $strResult .= $match[3] . ",";
+        $strResult .= $match[2] . ",";
+        $strResult .= "0<br>";
+    }
+
+    echo $strResult;
+}
+
+$html = <<< 'HERE'
+// Insérer code HTML page "limites" du CNG
+HERE;
+
+main($html);

+ 28 - 0
datasets/raphael/liste_villes_abrev_raph.csv

@@ -0,0 +1,28 @@
+15;AP-HP
+20;STRASBOURG
+18;NANCY
+16;BESANCON
+17;DIJON
+19;REIMS
+22;CAEN
+24;ROUEN
+23;LILLE
+21;AMIENS
+38;CLERMONT FERRAND
+25;GRENOBLE
+26;HCL
+27;SAINT ETIENNE
+29;BREST
+32;RENNES
+28;ANGERS
+30;NANTES
+33;TOURS
+31;POITIERS
+35;MONTPELLIER
+34;AP-HM
+36;NICE
+37;BORDEAUX
+42;LA REUNION
+40;TOULOUSE
+39;LIMOGES
+41;MARTINIQUE/POINTE A PITRE