Application that reads data from 3 files, orders racers by time, and prints a report showing two tables: the top 15 racers and the remaining racers.
Project description
Report of Monaco 2018 Racing
Installation
Clone this repository to your local machine:
Use the manager pip to install package:
pip install race-report
Summary
Application that read data from 3 files, order racers by time and print report that shows 2 tables: the top 15 racers and other racers. 🔴 Data should include 3 files: "start.log", "end.log", abbreviations.txt. 🔴
The files "start.log" and "end.log" should have lines in the format "SVF2018-05-24_12:02:58.917", where:
- SVF - racer abbreviation;
- 2018-05-24 - date;
- 12:02:58.917 - time;
In data and time underscore character (_) is used as a delimiter.
The third file abbreviations.txt contains abbreviation explanations, and should have lines in the format "DRR_Daniel Ricciardo_RED BULL RACING TAG HEUER", where:
- DRR - racer abbreviation;
- Daniel Ricciardo - full name of racer;
- RED BULL RACING TAG HEUER - racer team;
All data must be separated by underscore character (_).
If the data is invalid, you will receive an error or a red warning message in the console.
Usage
from race_report_by_ng import abbr_decoder, drivers_best_lap, build_report, print_report
drivers_abbreviations = abbr_decoder("data/abbreviations.txt")
drivers_best_time = drivers_best_lap("data/start.log", "data/end.log")
report = build_report(drivers_abbreviations, drivers_best_time)
print_report(report)
# Output:
# WARNING: Invalid time for EOF. The result is not added to the overall rating.
# +-------+-------------------+---------------------------+-------------+
# | Place | Driver name | Team | Best lap |
# +-------+-------------------+---------------------------+-------------+
# | 1. | Sebastian Vettel | FERRARI | 0:01:04.415 |
# | 2. | Valtteri Bottas | MERCEDES | 0:01:12.434 |
# | 3. | Stoffel Vandoorne | MCLAREN RENAULT | 0:01:12.463 |
# | 4. | Kimi Räikkönen | FERRARI | 0:01:12.639 |
# | 5. | Fernando Alonso | MCLAREN RENAULT | 0:01:12.657 |
# | 6. | Charles Leclerc | SAUBER FERRARI | 0:01:12.829 |
# | 7. | Sergio Perez | FORCE INDIA MERCEDES | 0:01:12.848 |
# | 8. | Romain Grosjean | HAAS FERRARI | 0:01:12.930 |
# | 9. | Pierre Gasly | SCUDERIA TORO ROSSO HONDA | 0:01:12.941 |
# | 10. | Carlos Sainz | RENAULT | 0:01:12.950 |
# | 11. | Nico Hulkenberg | RENAULT | 0:01:13.065 |
# | 12. | Brendon Hartley | SCUDERIA TORO ROSSO HONDA | 0:01:13.179 |
# | 13. | Marcus Ericsson | SAUBER FERRARI | 0:01:13.265 |
# | 14. | Lance Stroll | WILLIAMS MERCEDES | 0:01:13.323 |
# | 15. | Kevin Magnussen | HAAS FERRARI | 0:01:13.393 |
# +-------+-------------------+---------------------------+-------------+
Func print_report сan also show the tables in reverse order:
from race_report_by_ng import abbr_decoder, drivers_best_lap, build_report, print_report
drivers_abbreviations = abbr_decoder("data/abbreviations.txt")
drivers_best_time = drivers_best_lap("data/start.log", "data/end.log")
report = build_report(drivers_abbreviations, drivers_best_time)
print_report(report, desc=True)
# Output:
# +-------+-------------------+---------------------------+-------------+
# | Place | Driver name | Team | Best lap |
# +-------+-------------------+---------------------------+-------------+
# | 15 | Kevin Magnussen | HAAS FERRARI | 0:01:13.393 |
# | 14 | Lance Stroll | WILLIAMS MERCEDES | 0:01:13.323 |
# | 13 | Marcus Ericsson | SAUBER FERRARI | 0:01:13.265 |
# | 12 | Brendon Hartley | SCUDERIA TORO ROSSO HONDA | 0:01:13.179 |
# | 11 | Nico Hulkenberg | RENAULT | 0:01:13.065 |
# | 10 | Carlos Sainz | RENAULT | 0:01:12.950 |
# | 9 | Pierre Gasly | SCUDERIA TORO ROSSO HONDA | 0:01:12.941 |
# | 8 | Romain Grosjean | HAAS FERRARI | 0:01:12.930 |
# | 7 | Sergio Perez | FORCE INDIA MERCEDES | 0:01:12.848 |
# | 6 | Charles Leclerc | SAUBER FERRARI | 0:01:12.829 |
# | 5 | Fernando Alonso | MCLAREN RENAULT | 0:01:12.657 |
# | 4 | Kimi Räikkönen | FERRARI | 0:01:12.639 |
# | 3 | Stoffel Vandoorne | MCLAREN RENAULT | 0:01:12.463 |
# | 2 | Valtteri Bottas | MERCEDES | 0:01:12.434 |
# | 1 | Sebastian Vettel | FERRARI | 0:01:04.415 |
# +-------+-------------------+---------------------------+-------------+
Also implemented command-line interface(CLI):
# Print report
python report_cli.py --filles “path_to_folder”
# Print info about racer
python report_cli.py --filles “path_to_folder” --driver ”driver_full_name”
There is also a "--desc" parameter that can show the tables in reverse order:
# Print report
python report_cli.py --filles “path_to_folder” --desc
For more information about CLI, use:
python report_cli.py --help
Used
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file race_report-1.0.0.tar.gz.
File metadata
- Download URL: race_report-1.0.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb9ea645ae69538afd621cdfa2c58718f84be2cac0b02e476e69ef9471d6108f
|
|
| MD5 |
bd28035ca9d9c749e0991db6316b748e
|
|
| BLAKE2b-256 |
de9b4169da36d2c29421ab43d7beb33e526d69c1b0c70303a4d3feb1c864744c
|