Improved file handling, error handling, and runtime optimization in transcription parser #51
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.
Using the 'utf-8' encoding when opening files in the save_transcriptions and load_transcriptions functions, to avoid encoding errors when writing non-ASCII characters.
Using the start parameter in the enumerate function in the load_transcriptions function, to avoid confusing error messages in case of exceptions.
Using the rstrip function in the parse_transcription_line function, to remove any trailing white spaces and newlines from the transcription.
Optimizing the code for runtime and code cleanliness, by using list comprehension in the parse_transcription function to replace the for loop for appending transcriptions.
These changes should make the code more robust and handle various edge cases. I have tested the code with various transcription files and it works as expected.