generated from greek-learner-texts/text-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import codecs | ||
|
||
def replace_unicode_character(file_path, replacement=''): | ||
""" | ||
Replace specific Unicode character (U+200E) in the given file with the specified replacement. | ||
Args: | ||
- file_path: Path to the input file. | ||
- replacement: String to replace the Unicode character with. Defaults to an empty string. | ||
""" | ||
# Define the Unicode character to replace | ||
unicode_char_to_replace = '\u200E' | ||
|
||
# Read the original content of the file | ||
with codecs.open(file_path, 'r', encoding='utf-8') as file: | ||
content = file.read() | ||
|
||
# Replace the Unicode character with the desired replacement | ||
modified_content = content.replace(unicode_char_to_replace, replacement) | ||
|
||
# Write the modified content back to the file | ||
with codecs.open(file_path, 'w', encoding='utf-8') as file: | ||
file.write(modified_content) | ||
|
||
# Example usage | ||
file_path = '/content/Aristotle\'s Nicomachean Ethics -Limpo V15.txt' # Replace this with your actual file path | ||
replace_unicode_character(file_path) |