Wondering if the file has only comma separated values then why not save file as ".csv" format. If you can then:
You can always use a csv reader to read any CSV file as mentioned under the docs: http://docs.python.org/2/library/csv.html
Quick example for your scenario:
with open('test.csv','rb') as csvfile:
csvreader = csv.reader(csvfile)
output_fil = open('output.txt', 'ab')
for row in csvreader:
result = 0
for elem in row:
result = result + int(elem)
print result
output_fil.writelines(str(result))
Where text.csv would contain input like:
1,2,3
4,5,6
...
and output.txt shall contain:
6
15
..