'python, csv; compile data from four csv files; calculate average of data per number of days given

I'd like to write a program in Python involving the calculation of average infection data on Covid. The data is stored in a csv file. The user will have 4 different files to choose from: 2019.csv, 2020.csv, 2021.csv, 2022.csv. The data is stored quarterly (as a reminder, each year consists of 4 quarters :D). I would like the task to be more or less something like this:

  1. User selects two quarters.
  2. The program calculates the number of infections per Covid between quarters and calculates the daily average of infections.
  3. The program displays the data on the console.

The task doesn't seem to be very difficult, but the problem arises in that I don't know what to do when the user selects, for example, Q1 2019 and Q2 2021, because the program will also have to read and calculate the data in 2020. I know how to do when the user selects two quarters from the same year, because there will be a reading of data from one file. But what about in the case I described above?

Thanks for any form of help :P



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source