-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
48 lines (39 loc) · 1.27 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
title: "Extract ticket price from VVS Emails "
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning = FALSE)
library(stringr)
source("processfile.R")
source("findpattern.R")
source("make_email_list.R")
```
## Introduction
For the annual tax declaration, I wanted to find an automated way to find the total amount of money I have paid for online tickets.
The code below workks for Online tickets from Stuttgart and Munich.
The mails were exported from my Mail-App.
## Read Data
```{r}
filepath <- "ssb2018.mbox/mbox"
rawtextlist <- processFile(filepath)
head(rawtextlist)
```
## Parse Data
First we need to find thepoint were an email starts. Then we convert the emails in a list of strings. So every email is a one entry in a list.
The ticket price will be present multiple times in the email, also VAT. We only need one value per mail.
```{r}
#for the munich mvv it would be: "From ticketshop@mvv-muenchen.de"
mailstart <- "From ticketshop@ssb-ag.de"
emailStrinList <-makeEmaiStringList(rawTextList = rawtextlist, starterStr = mailstart)
head(emailStrinList)
```
### And now find the find the values
```{r}
erg <- lapply(emailStrinList, findValueInList)
```
## Result
And here it is:
```{r message=FALSE, warning=FALSE}
do.call(sum, erg)
```