{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Exercice sur des données persos\n", "\n", "## Récupération des données\n", "\n", "Récupération d'un listing de notes persos au format markdown.\n", "\n", "```shell\n", "ls 20* -d > tree.txt\n", "```" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['20200404193723_FirstNote.md',\n", " '20200404193815_SecondNote.md',\n", " '20200404193815_SecondNote.pdf',\n", " '20200406120140_PythonSciBasics.html',\n", " '20200406120140_PythonSciBasics.md',\n", " '20200406120140_PythonSciBasics.pdf',\n", " '20200406222521_OutilsPourMieuxCoder.md',\n", " '20200407101411_AnalyseSensibilite.md',\n", " '20200407102544_LTspice2latex.md',\n", " '20200407105048_latex2svg.md',\n", " '20200407171447_repetabiliteMesures.html',\n", " '20200407171447_repetabiliteMesures.md',\n", " '20200407172558_fideliteMesures.html',\n", " '20200407172558_fideliteMesures.md',\n", " '20200407172757_reproductibiliteMesures.html',\n", " '20200407172757_reproductibiliteMesures.md',\n", " '20200407174039_RechercheReproductible.md',\n", " '20200413171110_ExemplesCodesNonReproductibles.md',\n", " '20200413173245_GuideBonnesPratiquesNumeriquesBD.html',\n", " '20200413173245_GuideBonnesPratiquesNumeriquesBD.md',\n", " '20200413173245_GuideBonnesPratiquesNumeriquesBD.pdf',\n", " '20200501100000_DesignEcolo_EchangeEliseDiscord.md',\n", " '20200501115700_IAecolo_EchangeClementineDiscord.md',\n", " '20200502223100_MethodeKron.md',\n", " '20200502224900_PandocCitationCrossRef.md',\n", " '20200509142300_img/',\n", " '20200509142300_PredictionsClimat.md',\n", " '20200509173000_Retrobrighting.md',\n", " '20200515104700_img/',\n", " '20200515104700_ReparationPerforma400.md',\n", " '20200515142200_doc/',\n", " '20200515142200_ProgrammationMacOS7.md',\n", " '20200516161400_img/',\n", " '20200516161400_ReparationMacLC630.md',\n", " '20200519101800_ProgrammationScientifique.md',\n", " '20200526183300_Imprimante3D.md']" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import csv\n", "from os import getcwd, listdir\n", "\n", "listFiles = []\n", "with open('tree.txt', 'r', encoding='utf8') as myFile:\n", " myReader = csv.reader(myFile)\n", " for row in myReader:\n", " listFiles += row\n", "listFiles" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Séparation des notes et de leur dossier de pièces jointes :" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Calcul du nombre de notes écrites par jour\n", "\n", "Pour ce faire on retrouve la date dans le nom de chaque note. Et on compte le nombre de notes écrite pour ce jour. Chaque jour depuis la première date est analysé, même sans notes." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "import datetime\n", "\n", "firstNote = listNotes[0]\n", "lastNote = listNotes[-1]\n", "\n", "def findDate(filename):\n", " \n", "startDate = datetime.date(2020,1,1)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "datetime.date(2020, 2, 5)" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "startDate + datetime.timedelta(35,0,0)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.4" } }, "nbformat": 4, "nbformat_minor": 2 }