Question: Assume an input file has one or more numeric values separated by commas. We would like to create a file that contains those lines that

Assume an input file has one or more numeric values separated by commas. We would like to create a file that contains those lines that have two numeric
values and report to the screen those lines that have other than two values as well as lines with non-numeric values.
For example, if the input file has:
10.1,10.4
9.9,10.0,10.1
9.8,9.9x
the output file should have:
10.1,10.4
and the screen should display:
Line 2: not 2 values: 9.9,10.0,10.1
Line 3: non-numeric value: 9.8,9.9x
input_file_path = 'input_values.txt'
with open(input_file_path, 'w') as file:
output_file_path = 'output_values.txt' In addition, we need to prompt the user for the name of the input file and output file, like input_file = input("Please enter the input file name: ")
# Open the input file for reading
infile = open(input_file, 'r')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!