Last active
October 17, 2019 23:06
-
-
Save mbojan/bbdae569326a908e6d65ead2fe3bd0c0 to your computer and use it in GitHub Desktop.
Parse (broken) iCal to CSV suitable for Google Calendar
This file contains hidden or 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(ical) | |
library(dplyr) | |
library(tidyr) | |
library(lubridate) | |
d <- list.files("~/Downloads", "^[0-9]+.ics$", full.names = TRUE) %>% | |
lapply(ical::ical_parse_df) %>% | |
lapply(mutate_if, is.factor, as.character) %>% | |
bind_rows() %>% | |
as_tibble() | |
d %>% | |
separate( | |
summary, | |
into=c("name", "group", "room"), | |
sep = "; " | |
) %>% | |
transmute( | |
Subject = name, | |
Description = paste(name, group, room, sep=" -- "), | |
`Start Date` = strftime(start, format="%m/%d/%Y"), | |
`Start Time` = strftime(start, format="%I:%M %p", tz="CET"), | |
`End Date` = strftime(end, format="%m/%d/%Y"), | |
`End Time` = strftime(end, format="%I:%M %p", tz="CET") | |
) %>% | |
readr::write_csv(path="calendar.csv") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment