Début de l'analyse du journal pour le Module 2 exo 4

This commit is contained in:
Louis Lacoste 2022-11-20 11:20:26 +01:00
parent f4b6cc80f1
commit 912e8519b4
2 changed files with 65 additions and 0 deletions

View file

@ -0,0 +1,55 @@
#+TITLE: Analyse du journal
#+AUTHOR: Louis Lacoste
#+DATE: 2022-11-20
#+LANGUAGE: fr
# #+PROPERTY: header-args :eval never-export
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
#+HTML_HEAD: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
#+HTML_HEAD: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
* Récupération des données du journal
Ici nous allons importer les étiquettes et les exporter dans un
fichier =data.csv=.
#+begin_src shell :results output :exports both
grep -oP "(?<=:)([a-zA-Z]*)(?=:)" ~/org/journal.org > data.csv
head -n 5 data.csv
#+end_src
#+RESULTS:
: informatique
: wikipedia
: biologie
: virus
: allergie
* Traitement des données
#+NAME: import-python
#+begin_src python :results output :session :exports both :dir /home/polarolouis/Documents/MOOC/RR/mooc-rr/module2/exo4
import csv
with open('data.csv', 'r', encoding='utf8') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
print(row)
#+end_src
#+RESULTS: import-python
#+begin_example
['informatique']
['wikipedia']
['biologie']
['virus']
['allergie']
['biologie']
['LOGBOOK']
['END']
['LOGBOOK']
['END']
#+end_example

10
module2/exo4/data.csv Normal file
View file

@ -0,0 +1,10 @@
informatique
wikipedia
biologie
virus
allergie
biologie
LOGBOOK
END
LOGBOOK
END
1 informatique
2 wikipedia
3 biologie
4 virus
5 allergie
6 biologie
7 LOGBOOK
8 END
9 LOGBOOK
10 END