3,7 → 3,6 |
|
const DOSSIER_V0 = '../../../donnees/coste/0.00/'; |
const DOSSIER_V2 = '../../../donnees/coste/2.00/'; |
const DOSSIER_LOG = 'log/'; |
|
private $conteneur = null; |
private $outils = null; |
61,7 → 60,7 |
|
private function chargerIndexSp() { |
$spIndexFichier = $this->dossierBase.self::DOSSIER_V0.'index_general_sp.tsv'; |
$index = $this->transformerTxtTsvEnTableau($spIndexFichier); |
$index = $this->outils->transformerTxtTsvEnTableau($spIndexFichier); |
$index = $this->reindexerParNumNomCoste($index); |
foreach ($index as $numNomCoste => $infos) { |
$numTaxSup = ''; |
83,29 → 82,9 |
return $nouvelIndex; |
} |
|
/** |
* @link http://gist.github.com/385876 |
*/ |
private function transformerTxtTsvEnTableau($file = '', $delimiter = "\t") { |
$str = file_get_contents($file); |
$lines = explode("\n", $str); |
$field_names = explode($delimiter, array_shift($lines)); |
foreach ($lines as $line) { |
// Skip the empty line |
if (empty($line)) continue; |
$fields = explode($delimiter, $line); |
$_res = array(); |
foreach ($field_names as $key => $f) { |
$_res[$f] = isset($fields[$key]) ? $fields[$key] : ''; |
} |
$res[] = $_res; |
} |
return $res; |
} |
|
private function chargerIndexSupraSp() { |
$infraSpIndexFichier = $this->dossierBase.self::DOSSIER_V0.'index_general.tsv'; |
$this->supraSpIndex = $this->transformerTxtTsvEnTableau($infraSpIndexFichier); |
$this->supraSpIndex = $this->outils->transformerTxtTsvEnTableau($infraSpIndexFichier); |
foreach ($this->supraSpIndex as $cle => $infos) { |
$this->supraSpIndex[$cle]['num_nom_retenu_coste'] = $infos['num_nom_coste']; |
} |
151,7 → 130,7 |
} |
$infos['image'] = $this->obtenirNomFichierImg($nomRetenu); |
$infos['nbre_taxons'] = $this->obtenirNbreTaxon($infos); |
$infos['nbre_taxons'] = $infos['nbre_taxons']; |
$nomRetenu['nbre_taxons'] = $infos['nbre_taxons']; |
$infos['page_wiki_dsc'] = $this->genererPageWikiDsc($nomRetenu); |
$infos['page_wiki_cle'] = $this->genererPageWikiCle($nomRetenu); |
|
241,7 → 220,5 |
$fichierTsvIndexFinal = $this->dossierBase.self::DOSSIER_V2.'index.tsv'; |
file_put_contents($fichierTsvIndexFinal, $txt); |
} |
|
|
} |
?> |