add read / write from / to csv and move checking directory to helpers
This commit is contained in:
@@ -189,6 +189,25 @@ parse_rednerliste <- function(rednerliste_xml) {
|
||||
rolle_lang = d["rolle_lang",])
|
||||
}
|
||||
|
||||
write_to_csv <- function(tables, path="csv/", create=F) {
|
||||
check_directory(path, create)
|
||||
write.table(tables$redner, str_c(path, "redner.csv"))
|
||||
write.table(tables$reden, str_c(path, "reden.csv"))
|
||||
write.table(tables$talks, str_c(path, "talks.csv"))
|
||||
write.table(tables$comments, str_c(path, "comments.csv"))
|
||||
}
|
||||
|
||||
read_from_csv <- function(path="csv/") {
|
||||
list(redner = read.table(str_c(path, "redner.csv")) %>%
|
||||
tibble() %>%
|
||||
mutate(id = as.character(id)),
|
||||
reden = read.table(str_c(path, "reden.csv")) %>%
|
||||
tibble() %>%
|
||||
mutate(redner = as.character(redner)),
|
||||
talks = tibble %$% read.table(str_c(path, "talks.csv")),
|
||||
comments = tibble %$% read.table(str_c(path, "comments.csv")))
|
||||
}
|
||||
|
||||
# -------------------------------
|
||||
# EXAMPLE USE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user