Monday, 15 February 2010

use url pdf instead of file pdf in R -


I use the following line to import text from a PDF into R

I am
  Yuri  

However, I would like to use the URL from which I am getting PDF in my hard disk instead of PDF file in the first argument.

I suspect that the use of this line to create a local file url sample in readPDF document Does:

  Yuri and lieutenant; - sprintf ("file: //% s", system.file (file.path ("doc", "tm.pdf"), package = "TM"))  

< S> You do not need to do this for ftp or http url, just pass url as it is readPDF urls Only , so also the local file path has to be converted to URI.

You can just type:

  Yuri < - "http://cran.r-project.org/web/packages/tm/tm.pdf"  

to get the TM package documentation , Then go to readPDF :

  to read with Yuri - http://cran.r-project.org/web/ Packages / tm / tm .pdf "pdf" - readPDF (control = list (text = "-layout")) (elem = list (uri = uri), language = "en", id = "id1") <  

> ReadPDF essentially acts as a cover over external commands, so the URI is as to pdftotext (for xpdf) or whatever Use the command Or that understands the command URL, this will fail with this warning.

The only real option is to file locally Download.file with readPDF :

  Yuri <- "http: //cran.r-project. Org / web / packages / tm / tm.pdf "download. File (Yuri, "TMPDF", method = "internal", mode = "wb") PDF & lt; - readPDF (control = list (text = "-layout")) (elem = list (uri = "tm. PDF"), language = "n", id = "id1") content (pdf) [1:13 ]  

I am able to use a relative file path because the Yuri parameter has been passed, it is not considered as any URI. I was able to pass "h: \\ document \\ tm.pdf" and "h: /documents/tm.pdf" as well.


No comments:

Post a Comment