Skip to content

extract_table() returns error corresponding to working directory #169

@frandjango

Description

@frandjango

Question

Why does extract_table() return an error message corresponding to the working directory when the directory and the file exist?

Reproducible example

Below is the code where x is the full path to the pdf file. extract_table() does in fact return the tables, albeit with an error. The error seems to have something to do with the third object of the returned list.

I don't understand what it has to with the working directory. Please, may someone explain why this is happening and offer a suggestion to resolve the error?

Code

x <- list.files(full.names = TRUE)[1]
file.exists(x)
[1] TRUE

extract_tables(x, method = "decide")

Error : 'TOTAL PAYABLE  75,564.00   10,578.96   86,142.95' does not exist in current working directory ('C:/Users/<username>/OneDrive/Documents/Destination').                                    
[[1]]                                                                                                                                                                                  
# A tibble: 6 × 8
  QTY   ITEM         `KG/ITEM` `R/ITEM` `R/KG`  EXCL   VAT  INCL
  <chr> <chr>            <dbl>    <dbl>  <dbl> <dbl> <dbl> <dbl>
1 2     COW : BLACK        438     8500   19.4 17000  2380 19380
2 4     COW : BLK          481     9300   19.3 37200  5208 42408
3 1     COW : BLK          455     9400   20.7  9400  1316 10716
4 1     HEIFER : BLK       385     8800   22.9  8800  1232 10032
5 1     COW : RED          380     8750   23.0  8750  1225  9975
6 9+0   NA                4020       NA   NA   81150 11361 92511

[[2]]
# A tibble: 5 × 5
  `AAM COMMISSION` `5.00%`        `4,057.50` `568.05` `4,625.55`
  <chr>            <chr>               <dbl>    <dbl>      <dbl>
1 RMLA             Statutory Levy       51.0     7.14       58.2
2 RPO              0.15%               122.     17.0       139. 
3 FARMERS ASSOC    HDLA :: 0.5%m       406.     56.8       463. 
4 TRANSPORT        FRYSLAN             950     133        1083  
5 TOTAL DEDUCTIONS NA                 5586.    782.       6368. 

[[3]]
[1] "TOTAL PAYABLE\t75,564.00\t10,578.96\t86,142.95"

[[4]]
# A tibble: 3 × 7
  `CATEGORY SUMMARY`   QTY `R/KG` `TOTAL KG` `KG/ITEM` TOTAL `R/ITEM`
  <chr>              <dbl>  <dbl>      <dbl>     <dbl> <dbl>    <dbl>
1 COW                    8   19.9       3635       454 72350    9044.
2 HEIFER                 1   22.9        385       385  8800    8800 
3 TOTAL                  9   20.2       4020       447 81150    9017.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions