From 4093cb603c70de9af083cd1667e7fba6cc04edc2 Mon Sep 17 00:00:00 2001 From: flavis Date: Tue, 10 Aug 2021 11:22:29 +0200 Subject: [PATCH] add further checks for invalid records --- R/parse.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/R/parse.R b/R/parse.R index 4d59ffc..58cc3df 100644 --- a/R/parse.R +++ b/R/parse.R @@ -76,6 +76,13 @@ read_one <- function(name, path) { verlauf <- xml_find_first(x, "sitzungsverlauf") speakerl <- xml_find_first(x, "rednerliste") + # check if record is invalid or empty (every record should have at least + # one speech, a speaker and a date + if (is.na(date) || length(verlauf) == 0 || length(speakerl) == 0) { + warning("Invalid record found. Skipping.") + return(NULL) + } + xml_children(speakerl) %>% parse_speakerlist() -> speaker