{ "cells": [ { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "import csv\n", "with open('myjournal.csv','w',newline='') as fichiercsv:\n", " writer=csv.writer(fichiercsv)\n", " writer.writerow(['Date', 'Cahier', 'événement', 'heures_travail'])\n", " writer.writerow(['04/01/2022', 'projet_arduino', 'rdv_UCA', '8'])\n", " writer.writerow(['05/01/2022', 'partition_bach', 'zoom_XR', '12'])\n", " writer.writerow(['06/01/2022', 'cello_vocalise', 'rdv_CIRM', '9'])\n", " writer.writerow(['07/01/2022', 'formation_éthique', 'cours_en_ligne', '14'])\n", " writer.writerow(['08/01/2022', 'projet_collège', '', '13'])\n", " writer.writerow(['09/01/2022', 'partition_bach', 'zoom_prof', '8'])\n", " writer.writerow(['10/01/2022', 'cello_vocalise', 'répétition_CRR', '6'])\n", " writer.writerow(['11/01/2022', 'formation_articles', 'concert_CRR', '10'])\n", " \n" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "04/01/2022 projet_arduino\n", "05/01/2022 partition_bach\n", "06/01/2022 cello_vocalise\n", "07/01/2022 formation_éthique\n", "08/01/2022 projet_collège\n", "09/01/2022 partition_bach\n", "10/01/2022 cello_vocalise\n", "11/01/2022 formation_articles\n" ] } ], "source": [ "\n", " with open('myjournal.csv', newline='') as fichiercsv:\n", " reader = csv.DictReader(fichiercsv)\n", " for row in reader:\n", " print(row['Date'], row['Cahier'])\n", "\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "rdv_UCA\n", "zoom_XR\n", "rdv_CIRM\n", "cours_en_ligne\n", "\n", "zoom_prof\n", "répétition_CRR\n", "concert_CRR\n" ] } ], "source": [ "\n", " with open('myjournal.csv', newline='') as fichiercsv:\n", " reader = csv.DictReader(fichiercsv)\n", " for row in reader:\n", " print(row['événement'])" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['Date,Cahier,événement,heures_travail\\n']\n", "['04/01/2022,projet_arduino,rdv_UCA,8\\n', '05/01/2022,partition_bach,zoom_XR,12\\n', '06/01/2022,cello_vocalise,rdv_CIRM,9\\n', '07/01/2022,formation_éthique,cours_en_ligne,14\\n', '08/01/2022,projet_collège,,13\\n', '09/01/2022,partition_bach,zoom_prof,8\\n', '10/01/2022,cello_vocalise,répétition_CRR,6\\n', '11/01/2022,formation_articles,concert_CRR,10\\n']\n" ] } ], "source": [ "with open('myjournal.csv') as file:\n", " content = file.readlines()\n", "header = content[:1]\n", "rows = content[1:]\n", "print(header)\n", "print(rows)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Date | \n", "Cahier | \n", "événement | \n", "heures_travail | \n", "
---|---|---|---|---|
0 | \n", "04/01/2022 | \n", "projet_arduino | \n", "rdv_UCA | \n", "8 | \n", "
1 | \n", "05/01/2022 | \n", "partition_bach | \n", "zoom_XR | \n", "12 | \n", "
2 | \n", "06/01/2022 | \n", "cello_vocalise | \n", "rdv_CIRM | \n", "9 | \n", "
3 | \n", "07/01/2022 | \n", "formation_éthique | \n", "cours_en_ligne | \n", "14 | \n", "
4 | \n", "08/01/2022 | \n", "projet_collège | \n", "NaN | \n", "13 | \n", "
5 | \n", "09/01/2022 | \n", "partition_bach | \n", "zoom_prof | \n", "8 | \n", "
6 | \n", "10/01/2022 | \n", "cello_vocalise | \n", "répétition_CRR | \n", "6 | \n", "
7 | \n", "11/01/2022 | \n", "formation_articles | \n", "concert_CRR | \n", "10 | \n", "