From 21e0793c5472f95f49de3bbe6be1ad932025f96b Mon Sep 17 00:00:00 2001 From: cy_altern Date: Mon, 25 Jan 2021 00:53:12 +0100 Subject: [PATCH] =?UTF-8?q?page=20d'exploration=20des=20fichiers=20d'un=20?= =?UTF-8?q?corpus=20:=20extraction=201=C3=A8re=20et=20derni=C3=A8re=20lign?= =?UTF-8?q?e=20des=20fichiers=20jsonl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/mouline_corpus.html | 71 +++++++++++++++++++++++++++++++++++++ corpus_web_fonctions.php | 36 +++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 content/mouline_corpus.html diff --git a/content/mouline_corpus.html b/content/mouline_corpus.html new file mode 100644 index 0000000..69626c2 --- /dev/null +++ b/content/mouline_corpus.html @@ -0,0 +1,71 @@ +

Liste des fichiers disponibles

+
+ +
+ + + + \ No newline at end of file diff --git a/corpus_web_fonctions.php b/corpus_web_fonctions.php index be57e3a..d642bc1 100644 --- a/corpus_web_fonctions.php +++ b/corpus_web_fonctions.php @@ -12,3 +12,39 @@ if (!defined('_ECRIRE_INC_VERSION')) { return; } + + +function nombre_ligne($fichier) { + if (!file_exists($fichier)) { + return false; + } + $num_ligne = 0; + $handle = @fopen($fichier, "rb"); + if ($handle) { + while (($buffer = fgets($handle)) !== false) { + $num_ligne = $num_ligne + 1; + } + } + return $num_ligne; +} + +function affiche_ligne($fichier, $num) { + if (!file_exists($fichier)) { + return false; + } + + $handle = @fopen($fichier, "rb"); + if ($handle) { + while (($buffer = fgets($handle)) !== false) { + $num_ligne = $num_ligne + 1; + if ($num_ligne == $num) { + return $buffer; + } + } + if (!feof($handle)) { + echo "Erreur: fgets() a échoué\n"; + } + fclose($handle); + } + return 'Erreur : nombre de lignes du fichier '.$fichier.' inférieur à '.$num; +} \ No newline at end of file