""" file_summary.py Read in a file of numbers with commas between them on multiple lines. Write out a file with a summary that looks something like this: count: 23 total: 11234 average: 23.23 """ def main(): input_filename = 'data.txt' output_filename = 'summary.txt' # file = open(input_filename) stuff = file.read() stuff = stuff.strip() more_stuff = stuff.split(',') #print(more_stuff) numbers = [] for thing in more_stuff: splitty = thing.split('\n') for n in splitty: numbers.append(int(n)) #print(splitty) print(numbers) count = len(numbers) total = sum(numbers) output = open(output_filename, 'w') output.write('count: {:>14d}\n'.format(count)) output.write('total: {:>14d}\n'.format(total)) main()