Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

align get_csv_spec() utility functions with those used in read_portfolio_csv() #11

Open
cjyetman opened this issue Nov 26, 2022 · 0 comments

Comments

@cjyetman
Copy link
Member

cjyetman commented Nov 26, 2022

The R/get_csv_specs.R script includes a number of unexported utility functions. These functions should be extracted into their own script file or should be replaced by the equivalent functions being used by read_portfolio_csv() to avoid mis-alignment.

for example...

check_column_names <- function(filepaths, encodings, delimiters) {
vapply(
X = seq_along(filepaths),
FUN = function(i) {
readr::read_delim(file = filepaths[[i]], locale = readr::locale(encoding = encodings[[i]]), delim = delimiters[[i]], n_max = 1L, col_names = FALSE, show_col_types = FALSE, progress = FALSE)
},
FUN.VALUE = integer(1)
)
}

get_fields_per_line <- function(filepaths, tokenizers) {
vapply(
X = seq_along(filepaths),
FUN = function(i) {
list(
readr::count_fields(
file = filepaths[[i]],
tokenizer = tokenizers[[i]]
)
)
},
FUN.VALUE = list(1)
)
}

AB#10857

@cjyetman cjyetman changed the title align get_csv_spec() utility functions with those used in `read_portfolio_csv align get_csv_spec() utility functions with those used in read_portfolio_csv() Nov 26, 2022
@cjyetman cjyetman added the next label Apr 29, 2024
@jdhoffa jdhoffa added the ADO label Apr 30, 2024
cjyetman added a commit that referenced this issue Jun 28, 2024
previously, having an NA in either of the affected columns would fail,
as the `||` operator cannot cast NA to `logical()`

Will probably get clobbered when #11 gets addressed, but works in the
meantime.

---------

Co-authored-by: CJ Yetman <cyetman@rmi.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants