Skip to content

Commit

Permalink
Merge pull request nationalparkservice#124 from RobLBaker/main
Browse files Browse the repository at this point in the history
test_fields_match: more bug fixing
  • Loading branch information
RobLBaker authored Jan 12, 2024
2 parents b096e06 + a0c81a7 commit 4e2be28
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions R/tabular_data_congruence.R
Original file line number Diff line number Diff line change
Expand Up @@ -531,14 +531,19 @@ test_fields_match <- function(directory = here::here(), metadata = load_metadata
metadata_attrs <- lapply(data_tbl, function(tbl) {arcticdatautils::eml_get_simple(tbl, "attributeName")})
metadata_attrs$`@context` <- NULL

table_names <- EML::eml_get(data_tbl, "objectName")
table_names$`@context` <- NULL
#list all data files that are in data package
data_files <- list.files(path = directory, pattern = ".csv")

#get names of each file to add to attributes table
table_names <- NULL
for (i in 1:length(seq_along(data_files))) {
tbl_nam <- data_tbl[[i]][["physical"]][["objectName"]]
table_names <- append(table_names, tbl_nam)
}
#list metadata atttributes by file name
names(metadata_attrs) <- table_names
# for some reason this returns an error? replaced with the above 3 lines:
#names(metadata_attrs) <- arcticdatautils::eml_get_simple(data_tbl, "objectName")

# Get list of column names for each table in the csv data
data_files <- list.files(path = directory, pattern = ".csv")
data_colnames <- sapply(data_files, function(data_file) {names(readr::read_csv(file.path(directory, data_file), n_max = 1, show_col_types = FALSE))}, USE.NAMES = TRUE, simplify = FALSE)

# Quick check that tables match
Expand Down

0 comments on commit 4e2be28

Please sign in to comment.