Module: YnabTw::Converter
- Included in:
- YnabTw::Cathay::Converter, YnabTw::Cathay::CreditConverter
- Defined in:
- lib/ynab_tw/converter.rb
Instance Method Summary collapse
Instance Method Details
#convert(filename) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/ynab_tw/converter.rb', line 17 def convert(filename) csv = parse(filename) new_csv = convert_format(csv) header = "Date,Payee,Category,Memo,Outflow,Inflow\n" header + new_csv.map(&:to_csv).join("") end |
#parse(filename) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ynab_tw/converter.rb', line 6 def parse(filename) csv = nil File.open(filename, "r:big5:utf-8") do |f| lines = f.each_line.to_a ary = lines.drop(useless_header_count) csv_str = ary.join("") csv = ::CSV.parse(csv_str, headers: input_headers) end return csv end |