Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env Rscript
- library(readr)
- library(dplyr)
- library(magrittr)
- args = commandArgs(trailingOnly=TRUE)
- if (length(args) != 2) {
- stop("usage: nab2ynab.R nab.csv ynab.csv", call.=FALSE)
- }
- infile <- args[1]
- outfile <- args[2]
- data = read_csv(infile,skip = 6)
- data %<>% tbl_df
- ynab <-
- data %>%
- filter(grepl("^[0-9][0-9]\\.[0-9][0-9]\\.[0-9]{4}$",`Booking Date`)) %>%
- transmute(Date=sub("^([0-9][0-9])\\.([0-9][0-9])\\.([0-9]{4})$","\\1/\\2/\\3",`Booking Date`),
- Payee=sub("^([^,]*),.*$","\\1",Text),
- Category="",
- Memo=sub("^[^,]*,(.*)$","\\1",Text),
- Outflow=Debit,
- Inflow=Credit) %>%
- tbl_df
- write_csv(ynab, outfile, na="")
Add Comment
Please, Sign In to add comment