Created
August 13, 2014 09:22
-
-
Save shenqi/2e645c0a4e9d96ccc0c7 to your computer and use it in GitHub Desktop.
りそなダイレクトからダウンロードできる入出金明細データとVISAデビットデータを組み合わせて見やすいCSVファイルを出力する
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
library(stringr) | |
# 出入金レコード | |
b <- read.csv('bank statement.csv', fileEncoding='cp932') | |
b$date <- paste0(b$取扱日付.年,'/',b$取扱日付.月,'/',b$取扱日付.日) | |
b$amount <- ifelse(b$取引名 == '入金', b$金額, -b$金額) | |
b$detail <- ifelse(str_detect(b$摘要, 'VISA'), str_sub(b$摘要, 11, 16), as.character(b$摘要)) | |
b$payee <- ifelse(str_detect(b$摘要, 'VISA'), '', as.character(b$摘要)) | |
# b[,22:25] | |
# VISAレコード | |
v <- read.csv('visa statement.csv', fileEncoding='cp932')[,c(14,20)] | |
names(v) <- c('payee', 'detail') | |
# 結合 | |
c <- merge(b[,22:25], v, by='detail', all=T)[-1,-1] | |
c$payee <- paste0(c$payee.x, c$payee.y) | |
# 出力 | |
write.csv(c[,c(-3, -4)], 'combined statement.csv') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment