Skip to content

Commit

Permalink
Solves #48 and #31
Browse files Browse the repository at this point in the history
  • Loading branch information
gistin committed Dec 21, 2023
1 parent 99a6296 commit 6efbb66
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions R/import-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
#'
#' @import dplyr stringr readr
import_csv <- function(path) {
data <- read_csv(path, show_col_types=FALSE, progress=FALSE)
#######handles ; and ,#######
browser()
fl <- readLines(path, n = 1)
numfields <- count.fields(textConnection(fl), sep = ";")
if (numfields == 1) data <- read.csv(path,fileEncoding="latin1") else data <- read.csv2(path,fileEncoding="latin1")

#data <- read_csv(path, show_col_types=FALSE, progress=FALSE)
data <- rename_with(data, str_to_lower)
############check for lat or long fields and rename
colnames(data)[which("lat"== colnames(data))] <- "latitude"
Expand All @@ -37,7 +43,8 @@ import_csv <- function(path) {
data$geocat_deleted <- FALSE
data$geocat_id <- paste0("csv", seq(1, nrow(data)))
data$geocat_notes <- NA_character_

#####

data
}

Expand Down

0 comments on commit 6efbb66

Please sign in to comment.