Skip to content

Instantly share code, notes, and snippets.

@mbojan
Last active October 17, 2019 23:06
Show Gist options
  • Save mbojan/bbdae569326a908e6d65ead2fe3bd0c0 to your computer and use it in GitHub Desktop.
Save mbojan/bbdae569326a908e6d65ead2fe3bd0c0 to your computer and use it in GitHub Desktop.
Parse (broken) iCal to CSV suitable for Google Calendar
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