Description
Objective:
Read names from two different files into your program and write each name to a single new file.
Please make sure you download the namelist1.txt & namelist2.txt input files from the assignment page in Canvas and place them in the same folder as your program.
– Input files:
– nameslist1.txt & nameslist2.txt
– Each file contains a list of 200 unique names.
– Output file:
– Output all names to an output file called allnames.txt
Write a program that reads the names from the two input files and writes the names to the two output files:
a. Ask the user to input the file name and path of the first input file.
i. Use a try/except block to open all input before processing.
ii. If the file cannot be opened, display the appropriate error message and require the user to reenter the file name and path.
iii. Continue looping until the user has entered a valid file name and path.
b. Ask the user to input the file name and path of the second input file.
i. Use a try/except block to open all input before processing.
ii. If the file cannot be opened, display the appropriate error message and require the user to reenter the file name and path.
iii. Continue looping until the user has entered a valid file name and path.
c. Ask the user to input the file name and path of the output file.
i. Use a try/except block to open all input before processing.
ii. If the file cannot be opened, display the appropriate error message and require the user to reenter the file name and path.
iii. Continue looping until the user has entered a valid file name and path.
d. Processing:
i. Use a try/except block to read from the input files and write to the output file.
ii. Read all the names from one input file at a time. Write the names to the output file.
– You must use a while loop to process the first input file (nameslist1.txt) and write to the output file.
– You must use a for loop to process the second input file (nameslist2.txt) and write to the output file.
iii. Each line in each input file is one name.
iv. Each name must be written on a separate line in the output file.
v. There must be no blank lines between names in the output files.
e. All input files and the output file must be closed after all names have been processed.
Rubric:
The rubric is located on the assignment page in Canvas. Please review the rubric to make sure you meet all of the requirements for this lab.
Screen Shot:
Enter the path and name of the first file: c:test Terr.txt
Error: file(s) not found, or could not be opened
Please reenter
Enter the path and name of the first file: c:testnameslist1.txt
Enter the path and name of the second file: c:testerr.txt
Error: file(s) not found, or could not be opened
Please reenter
Enter the path and name of the second file: c:testnameslist2.txt
Enter the path and name of the output file: c:testallnames.txt
Names processing started
Names processing complete
Christina Martini –
Work was finished long before due and tutor was considerate and engaging. Perfect!
Jed Friend –
Thanks a lots, I really appreciate your effort it is an excellent report.