ファイルの読み書きの備忘
sample.rb
#ファイルの読込
orderSum = {}
with open('input/input.txt', 'r', encoding='utf-8') as f:
for row in f:
data = row.rstrip().split(',')
name = data[0]
order = data[1]
if order in orderSum:
orderSum[order] += 1
else:
orderSum[order] = 1
with open('output/output.txt', 'w', encoding='utf-8') as f:
for key, value in orderSum.items():
f.write(key + ':' + str(value) + '\n')