Fix file reading and writing functions in main.py#392
Open
Kimhyojung0810 wants to merge 2 commits intoagwaBom:mainfrom
Open
Fix file reading and writing functions in main.py#392Kimhyojung0810 wants to merge 2 commits intoagwaBom:mainfrom
Kimhyojung0810 wants to merge 2 commits intoagwaBom:mainfrom
Conversation
Fix file reading and writing functions in main.py
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 PR fixes two incorrect functions in main.py so that the script can properly read english.txt and german.txt and generate the required concated.json output for the assignment.
Original code
Updated code
The file was opened in write mode 'w', which clears the file and prevents reading. No lines were actually read from the file. The variable lines was never defined, causing a NameError. As a result, the function could not return the English/German lines needed to build the JSON output.
Original code
Updated code
The file was opened in read mode 'r', so nothing could be written to the output file. The loop wrote only newline characters and did not write the actual strings in file_list. Because of this, the expected JSON lines would never appear in concated.json.
With these two fixes, the script now correctly reads both input files and writes the expected JSON lines into
concated.json, completing the assignment requirements.