add further checks for invalid records

This commit is contained in:
2021-08-10 11:22:29 +02:00
parent 1152115a0f
commit 4093cb603c
+7
View File
@@ -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