Skip to content

Commit

Permalink
fix encoding issues in read_flights()
Browse files Browse the repository at this point in the history
  • Loading branch information
rafapereirabr committed Apr 22, 2024
1 parent 485ec1d commit 88aba0c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: flightsbr
Title: Download Flight and Airport Data from Brazil
Version: 0.4.0
Version: 0.4.09999
Authors@R:
c(person(given="Rafael H. M.", family="Pereira",
email="[email protected]",
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# flightsbr v0.4.1 dev

* Minor changes:
* The `read_flights()` function now used `encoding = 'Latin-1'` internally to avoid issues with encoding. Closed #35.
* The function `get_airport_movement_dates_available()` does not throw warnings of `NA` values anymore.


# flightsbr v0.4.0

* Major changes:
Expand Down
7 changes: 5 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ get_airport_movement_dates_available <- function(date=NULL) {
csv_urls <- gsub('.csv.csv', '.csv', csv_urls, fixed = TRUE)

# get all dates available
all_dates <- substr(csv_urls , (nchar(csv_urls ) + 1) -10, nchar(csv_urls )-4 )
all_dates <- regmatches(csv_urls, gregexpr("\\d{6}", csv_urls))
all_dates <- unlist(unique(all_dates))
all_dates <- as.numeric(all_dates)

return(all_dates)
}

Expand Down Expand Up @@ -467,7 +469,8 @@ download_flights_data <- function(file_url = parent.frame()$file_url,
dt <- data.table::fread( paste0(temp_local_dir,'/', file_name),
select = select,
colClasses = 'character',
sep = ';')
sep = ';',
encoding = 'Latin-1')

# return to original threads
data.table::setDTthreads(orig_threads)
Expand Down

0 comments on commit 88aba0c

Please sign in to comment.