pdf_to_csv: Convert a page from a pdf file to a csv file

View source: R/pdf_to_csv.R

pdf_to_csvR Documentation

Convert a page from a pdf file to a csv file

Description

pdf_to_csv takes as input a pdf file and a page number and converts that to a data.frame and, optionally, saves that to a csv file. This can be useful for getting client-supplied data into a useful format. NOTE: This requires the package pdftools, which you may have to download and install with install.packages("pdftools"). You only have to do that once.

Usage

pdf_to_csv(pdf_file, page, save_csv = "csv")

Arguments

pdf_file

the pdf file you want to read, in quotes, e.g., pdf_file = "Table data that I want to graph but is in pdf form.pdf"

page

page number(s) of the pdf you want to read as a numeric vector. For example, to read page 10, use page = 10. To read pages 1, 3, and 5 and put them into a single csv file: page = c(1, 3, 5). To read pages 9 through 12: page = 9:12. If you use multiple pages, keep in mind that, if the columns don't line up well in the pdf, they also won't line up well in the output csv file.

save_csv

optionally specify a file name for saving the output. If left as "csv", the file name will be the pdf file name plus the 1st page number requested. If set to NA, no file will be saved.

Value

a data.frame of pdf table content

Examples

# No examples yet.


shirewoman2/Consultancy documentation built on Feb. 18, 2025, 10 p.m.