Skip to content

Commit

Permalink
separate out waystations in data cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronGullickson committed Sep 9, 2019
1 parent 2bb8970 commit e5ccab4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion clean_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ planets <- read_xml(here("input","planets.xml"))
#events <- read_xml(here("input","0002_planetevents.xml"))
connectors <- read_xml(here("input","1000_connectors.xml"))

#load in waystation information for identification
waystation_id <- as.character(read.csv(here("input","waystations.csv"))$id)

#now run through planets and separate out the events as well
#as connectors
new_planets <- xml_new_document() %>% xml_add_child("planets")
waystations <- xml_new_document() %>% xml_add_child("planets")
new_events <- xml_new_document() %>% xml_add_child("planets")

for(i in 1:xml_length(planets)) {
Expand Down Expand Up @@ -53,7 +57,12 @@ for(i in 1:xml_length(planets)) {
#
# If we are still here cycle through nodes and spit out results to the
# new file
planet_node <- xml_add_child(new_planets, "planet")
#check to see if its a waystation
if(id %in% waystation_id) {
planet_node <- xml_add_child(waystations, "planet")
} else {
planet_node <- xml_add_child(new_planets, "planet")
}
for(node in xml_children(planet)) {
#run a check on names to get rid of parenthetical stuff for planet number
#or name changes
Expand Down Expand Up @@ -87,6 +96,7 @@ for(i in 1:xml_length(planets)) {
}

cat(as.character(new_planets), file = here("output","planets_initial.xml"))
cat(as.character(waystations), file = here("output","waystations.xml"))
cat(as.character(new_events), file = here("output","planetevents_initial.xml"))

#ok clean up connectors now
Expand Down

0 comments on commit e5ccab4

Please sign in to comment.