Add CSV saving functionality for speed test results#2
Open
enzomarx wants to merge 2 commits intoLELIONTRIBAL0:mainfrom
Open
Add CSV saving functionality for speed test results#2enzomarx wants to merge 2 commits intoLELIONTRIBAL0:mainfrom
enzomarx wants to merge 2 commits intoLELIONTRIBAL0:mainfrom
Conversation
Added functionality to save speed test results to a CSV file, including timestamp and relevant metrics. Implemented error handling for file operations.
2dbc2b1 to
d133190
Compare
adaf38a to
01df013
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request implements the functionality to save speed test results to a persistent CSV file (speedtest_history.csv).
(Why is this change necessary?)
Currently, the script is ephemeral. The results are displayed in the console, but are lost as soon as the execution ends.
This feature transforms the tool from a "one-time test" to a "monitoring tool," allowing users to do something they couldn't before: build a history of their internet performance, analyze connection patterns, and keep a record of the tests.
Changes Made->
New imports: Addition of the native csv and os and datetime libraries for file manipulation and timestamps. New Function: Creation of save_results_csv(data_row), which manages the logic for writing to the file. It checks if the speedtest_history.csv file already exists. If it doesn't exist, it creates the file and writes the headers. If it already exists, it simply appends the new results row. Modification to main(): At the end of the execution, the test data (Download, Upload, Ping, ISP, etc.) are collected in a dictionary and passed to the save_results_csv() function.
This is a "non-destructive" addition (non-breaking change) and does not alter any of the original functionalities, it only adds the saving step at the end.