Introduction

In this test, we'll repeat the previous one by working directly from this pre-written jupyter notebook. Start by configuring the file paths in the cell below. Make sure that you are using the appropriate file path for you system. If you have Mac, remove the # from the beginning of the second input_path and output_path lines and type it at the beginning of the first input_path and output_path lines, which contain C:\\. When you are finished, type Shift+Enter. If nothing happens, your configuration was successful. If you get an error, go back and check your file paths.


In [ ]:
##### Configuration #####

# Configure the filename
filename = "file.txt"

# Configure the path to input directory
input_path = "C:\Users\USERNAME\Desktop\we1s-test\input"
# input_path = "/Users/USERNAME/Desktop/we1s-test/input"

# Configure the path to output directory
output_path = "C:\Users\USERNAME\Desktop\we1s-test\output"
# output_path = "/Users/USERNAME/Desktop/we1s-test/output"

##### End of Configuration #####

Now you are ready to run the main part of the code. Click on the cell below and then type Shift+Enter. If you do not get an error, you should receive a message indicating that a new file has been written to your output folder.


In [ ]:
# Import the os package to manage file paths
import os

# Create input and out file paths
input_file = os.path.join(input_path, filename)
output_file = os.path.join(output_path, filename)

# Open the input file and read it
f = open(input_file)
text = f.read()
f.close()
print("The input file says: " + text)

# Convert the text to lower case
text = text.lower()

# Open the output file for writing and save the new text to it
output_file = os.path.join(output_path, "file2.txt")
f = open(output_file, "w")
f.write(text)
f.close()
print("I've just written a new file called 'file2.txt' to your output folder. Check it out!")

If you did not receive an error, you have successfully run the jupyter notebook test. You can now exit from jupyter notebooks. To do this, close the jupyter notebooks windows and return to the command or terminal prompt. Type Control/Command+c to interrupt the Python process. You may have to do this several times. Once the process is interrupted, you can type exit followed by enter to exit from the command prompt or terminal.