Skip to main content

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_by_ng

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

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

race_report-0.0.1.tar.gz (6.0 kB view details)

Uploaded Source

File details

Details for the file race_report-0.0.1.tar.gz.

File metadata

  • Download URL: race_report-0.0.1.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

Hashes for race_report-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1d64e098c85d042c38c8e23749eeb1ef743c28268b163c360fd7df564d46db64
MD5 3ff6d738ba1635ca44fe19f55b7d7120
BLAKE2b-256 252a8c3bc69b46755a56443e053e8b8892f773d52338a3d89062fe5f0f792504

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page