Created
January 3, 2015 17:22
-
-
Save biwakonbu/bd776a93a1f4ba0c6e5b to your computer and use it in GitHub Desktop.
SBI ネットバンク総投資額計算スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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