Testing the Program Tester

We want to test the Program Tester using a simple program.  Create a program called sumline.py which can be called from the command line using either Python 2.x or Python3.x.  It reads an input file and writes an output file whose names are given to it on the command line:

python  sumline.py  someinput.txt  someoutput.txt

or

python3 sumline.py someinput.txt  someoutput.txt

The program will be provided with an input file consisting of lines with values separated by commas (but may contain many spaces). Your program reads each input line, and if there are any positive integer values, then it calculates the sum of all the positive integer values found on that line.  You should ignore (no output) any line with no positive integer values to add.  The first line of your Python program will indicate whether it should be interpreted by Python 2.x or 3.x, and therefore must be:

#! /usr/bin/python

or

#! /usr/bin/python3

 

Assume that the file fred.txt contains the following data:

34,-1,3
hi,12,  5  ,there34
,,blurp
0,0,
42

If your program is called as follows...

python  sumline.py  fred.txt  george.txt

... then george.txt should contain:

37
17
42