Skip to content

Non-default file in mem_import throws read.csv error #2

Description

@ParfaitG

Slight adjustment may be needed for optional file parameter in mem_import(). Right now, if users set file parameter, file_path is never assigned and hence throws error at read.csv line. Possibly add an else condition to set file_path equal to file parameter. See example below:

Current

meetup_import <- function(file = NULL, format = "%d-%b-%y", ...) {

if(is.null(file) == TRUE) {
        file_path <- paste0(getwd(), "/data-raw/meetup/", list.files("data-raw/meetup", pattern = ".csv$"))
}
        
member_list <- read.csv(file = file_path, stringsAsFactors=FALSE, ...)

...

Adusted

meetup_import <- function(file = NULL, format = "%d-%b-%y", ...) {

if(is.null(file) == TRUE) {
        file_path <- paste0(getwd(), "/data-raw/meetup/", list.files("data-raw/meetup", pattern = ".csv$"))
} else {
        file_path <- file
}
        
member_list <- read.csv(file = file_path, stringsAsFactors=FALSE, ...)

...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions