Parse tables split across multiple pages on pdf, in single table, in r

Viewed 292

How can I parse a data (table) which has been split across multiple pages on a pdf document here into a single table in R?

Code I have tried - I am still wondering how can it be done, as I am not good in parsing text files.

Please help?

1 Answers

With the following code, you just need now to separate the columns of the dataframe df (you can use Excel for that):

library(pdftools)
library(tidyverse)

text <- pdf_text("consolidated transfer orders.pdf")

df <- map_dfr(1:length(text),
        ~ str_extract_all(text[.x],"(?<=\\n\\s{1,3})\\d+\\s+(.*)") %>%
          unlist() %>% data.frame())
Related