#!/usr/bin/env ruby require 'csv' kuni = CSV.read("capital.csv", headers:true) kuni.each do |row| printf("%s の首都は %s です。\n", row["国"], row["首都"]) end print("足したい国: ") country = gets.chomp print("首都: ") capital = gets.chomp CSV.open("capital.csv", "a") do |c| c << [country, capital] end