Première partie de l'exercice.

parent d21a887b
{
"cells": [],
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Analyse des mots-clés de mon journal"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Mise en forme de mon journal\n",
"Mes paragraphes sont titrés \"Date:JJ/MM/AAAA\".\n",
"\n",
"La première ligne du paragraphe contient [Mots Clés:Xxxx,Yyyy,Zzzz] où Xxxx, Yyyy, Zzzz sont des mots-clés."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Recupération des données"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"NomFichentree = \"work/Journal/Readme_Journal.md\"\n",
"NomFichsortie = \"work/module2/exo4/Info_Journal.csv\"\n",
"\n",
"with open(NomFichsortie, \"w\", encoding='utf-8') as sortie:\n",
" with open(NomFichentree, \"r\", encoding='utf-8') as entree:\n",
" for ligne in entree:\n",
" if \"Date:\" in ligne:\n",
" (rien,date) = ligne.lstrip('## ').strip().split(':')\n",
" if \"Mots Clés\" in ligne:\n",
" (rien,mots) = ligne.strip('Mots Clés').split(':')\n",
" listemots = mots.strip().split(',')\n",
" for mot in listemots:\n",
" sortie.write(f\"{date};{mot}\\n\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
......@@ -16,10 +62,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
"version": "3.6.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Markdown is supported
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