Skip to content

Instantly share code, notes, and snippets.

@biwakonbu
Created January 3, 2015 17:22
Show Gist options
  • Save biwakonbu/bd776a93a1f4ba0c6e5b to your computer and use it in GitHub Desktop.
Save biwakonbu/bd776a93a1f4ba0c6e5b to your computer and use it in GitHub Desktop.
SBI ネットバンク総投資額計算スクリプト
# coding: utf-8
require 'csv'
_header, *table = CSV.read(ARGV[0], encoding: 'cp932:utf-8')
SBI = 'SBIハイブリッド預金'
def column_sum(table, num)
table.map do |item|
if item[1] == SBI and item[num]
item[num].sub(',', '').to_i
else
0
end
end.reduce(:+)
end
def jpy(money)
(money / 10_000.0).to_s + ' 万円'
end
deposit = column_sum(table, 3)
payment = column_sum(table, 2)
puts '入金額 ' + jpy(deposit)
puts '出金額 ' + jpy(payment)
puts '株式投資額 ' + jpy(payment - deposit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment