“A friend sent me a list of exams”

The input

Vous receive this string from a friend, it represents a list of all his/her examinations. You copy it and you store it in a .txt file. """ Samedi 23 : 14h - 18h : MES (Méthodologie Enquête Sondage) Mardi 26 : 16h30 - 18h30 : Finance Samedi 6 juin : 9-12 : stats 2ème 16 juin : : Oral Ndls """ You can retrieve the information of "when you saved it to a txt file" using the "last-time modified date" of the file (or on windows, you can choose the "created date"). This information is easily available in python. You msut parse the string into the following format : {day_of_month}, {year}-{month}/{day}, {hour}:{minute} {end_hour}:{end_minute}, {name} The day of month must be in lowercase, a parameter can be added to your program to choose the language.

The csv file and the ods file

This file will be saved as a "csv" file. In our example, the .csv file would look like this (but of course this should work with other values) : samedi, 2020-05-23 mai, 14:00, 18:00, MES (Méthodologie Enquête Sondage) mardi, 2020-05-26, 16h30, 18h30, Finance samedi, 2020-06-06, 09:00, 12:00, stats 2ème mardi, 2020-06-16, unknown, unknown, Oral Ndls In the beginning you don't have to write directly to a file, you can use print. When you managed to write it to an .csv file, open it using Miscrosoft Excel or Libreoffice Calc or google sheets or office online Excel. Libreoffice is free and store it's spredsheet files as ".ods" (open document spreadsheet). If you want you can separate into two columns "MES" and "Méthodologie Enquête Sondage", the first one is the name, the second one is the "long name". Sometimes, the long name is empty (when there are no parenthesis).

The ods file and some graphs

- Create a graph where X = date of the exam and Y = hour of the beginning of the exam. If the hour is unknown, remove the exam from the graph - Create a bar graph where each bar is labelled by the name of the exam and the value is the hour of beginning Note: If the hour is unknown, remove the exam from the graph Note: if you need, you can add another column being the "timestamp" of the date of the exam. A popular timestamp format is the "Unix timestamp".

The matrix and the json file

After that, if you want, write a code that reads the csv file and convert into one of those python formats : Choice 1: A matrix where lines are like ["samedi", 2020, 5, 23, 14, 0, 18, 0, "MES (Méthodologie Enquête Sondage)"] Choice 2: A list of dictionnaries like { "day": "samedi", "date": "2020-05-23", "name": "MES (Méthodologie Enquête Sondage)", "beg_hour": 14, "beg_min": 0, "end_hour": 18, "end_min": 0 } The two formats can be saved as json file (using import json module). You can compute for example, the length of all of the exams.

Specifications details

1) If no month is provided, like when "mardi 26" is written. 1.1) (easy) you can consider it's current month (or date of the message) 1.2) (hard) it's must search the current year for the day at the given information, "mardi 23" will search for all Tuesday the 23rd, if two words exist, raise a ValueError (using code raise ValueError and a message saying "There exist two mardi 23 for year 2020"). 2) When you don't know what to choose, add a parameter to your program (using input or sys.argv or argparse). 3) The name of the file to translate can also be a parameter of the program.

Some tips

- Read "théorie 2", especially the part talking about "string" (theory 2). - To open a txt file read the theory about file. - Here is another theory file about matrices and dictionaries. - To manage datetime, use from datetime import datetime. For instance datetime(2020, 5, 20) can be used to create a datetime and datetime.now() will give the current time as a datetime. - To convert from and to json file, use import json. - To know more about modules (like random, datetime or json), read the module theory file. - Pro tip: regex (import re) How to handle the assignment : - Using a git repository, just the url sent by mail - Or a zip file containing the files needed for the assignment (the txt file, your python file(s) needed (if more than one file, the main one should be called "main.py"), your .ods or .xlsx file containing the graphs). You must handle the assignement each Friday (if you have something of course), I will respond to the mail to give you tips until you finish the assignment (some people will need 1 week, others will need more). Cite your sources when you use information from the internet ! If you have any question, contact me on messenger or by mail using the school email adress, even if your question is "I did not understand this part of the assignment".