Skip to content

Check tables for required fields as part of write_dwc() #538

@peterdesmet

Description

@peterdesmet

I tried providing the 2015_PHD_VERHELST_COD deposit at https://doi.org/10.14284/435 to write_dwc(). But the columns in our tables have changed slightly since, such as adding tag_serial_number in animals, which is not present in the deposited data.

Hence, I got:

Error in `dplyr::select()` at etn/R/create_animals_occurrence.R:67:3:
! Can't select columns that don't exist.
✖ Column `tag_serial_number` doesn't exist.
Run `rlang::last_trace()` to see where the error occurred.
Warning message:
One or more parsing issues, call `problems()` on your data frame for details,
e.g.:
  dat <- vroom(...)
  problems(dat) 

I think it would be good to capture required columns and provide a nice error. In movepub, we do this with check_ref() and check_gps(), see https://github.com/inbo/movepub/blob/main/R/check_ref.R

Adding on function per table would add quite a lot of functions, so I would opt for a generic check_table(name = "animals") and call it from write_dwc() (cf. movepub).


This is an enhancement, the current functionality is ok, just a bit hard to debug for the user.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions