ipeaGIT / flightsbr

R Package to Download Flight and Airport Data from Brazil
https://ipeagit.github.io/flightsbr/
Other
41 stars 6 forks source link

Error when using read_flights #35

Closed denisecammarota closed 6 months ago

denisecammarota commented 6 months ago

Hello, I was trying to download the data from 2015, with type being either 'basica' or 'combinada' and for both types I get error as well as waning messages. For type = 'basica': image For type = 'combinada': image In this last case, the data ends up loading, but the encoding appears like this: image Similar things happened for year = 2001, for example. I am working on R version 4.2.3 on windows. Thank you so much for your attention, as well as for the package!

rafapereirabr commented 6 months ago

Hi @denisecammarota . I suspect it must a problem during the data download. For some reason, file is downloaded but it gets corrupted.

I will need some time to investigate this in more detail. In the mean time, try running the function with cache = T, and it should work.

df <- read_flights(date = 2015, cache = T)

denisecammarota commented 6 months ago

Thank you so much for the answer. I tried and still with the option cache = T, which I think it is the default, and with cache = F, the data download seems to be having some problem in both cases. image

rafapereirabr commented 6 months ago

Hi @denisecammarota.

  1. The warning message occurs because of some issue with the original data set that messes up with the columns / rows. In the year 2015, this issue is only present on the data sets for November and December. The package is still able to read the data using data.table::fread() but it throws this warning message. I'm afraid there's not much I can do about it because it's an issue with the original data set provided by ANAC but I believe this is not big problem sinc fread can still read the data
  2. I've added the code of the package so now the read_flights() function now used encoding = 'Latin-1' internally to avoid issues with encoding. This should solve the problem with special characters in some columns.
  3. finally, the error does seems to be related to internet connection issues. Sometimes this issue might originate from the users internet connection but I'm afraid sometimes it might originate from instabilities in ANAC's connection. In either case, I'm not sure there's much I can do from the side of the {flightsbr} package.
denisecammarota commented 6 months ago

Thank you! I was able to read, encoded again for some special characters and everything worked fine, no errors!

rafapereirabr commented 6 months ago

I'm glad to hear this. I'll be shipping an updated version on CRAN asap.