This Python script provides functionality to handle text files, including reading, analyzing, and modifying their content.
- Python 3.12.2
-
Clone or download this repository in your computer.
-
Open a terminal or command prompt in your vs code or any other editor.
-
Navigate to the directory where the script is located.
-
Run the script using the following command: 'python text_analysis.py'
-
Follow the on-screen instructions to perform text analysis and modification.
text_analysis.py: The main Python script file.sample.txt: An example text file for testing the script.
read_txt_file(file_path): Reads content from a text file.analyze_text(text): Performs basic text analysis, including counting words, lines, and characters.modify_text(file_path, old_word, new_word): Modifies the content of a text file by replacing old words with new words.
To replace the word "Python" with "Java" in the sample text file:
- Run the script.
- Enter "Python" when prompted for the word you want to replace.
- Enter "Java" when prompted for the new word.
- The modified content will be written back to the sample text file.