Skip to content

Instantly share code, notes, and snippets.

@apoorv74
Last active May 29, 2019 05:08
Show Gist options
  • Save apoorv74/93d8fa8eb90c04717d26995fcd6d2165 to your computer and use it in GitHub Desktop.
Save apoorv74/93d8fa8eb90c04717d26995fcd6d2165 to your computer and use it in GitHub Desktop.
library(rvest)
library(readr)
# This file needs to be read as text.
x <- readr::read_file("~/Downloads/Chandigarh.xls")
# Every file will have a table, the way it is structured in this sample. We just want to extract this table and convert it to a data frame
# Check and clean the file as per the structure of the original one. Headers and Rows need to be adjusted.
y <- x %>% read_html() %>% html_table(fill = TRUE)
z <- y[[1]]
View(z)
# To get all headers
y <- x %>% read_html() %>% html_nodes(css = '.header') %>% html_text()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment