Rafnuss / GeoPressureR

Global positioning by atmospheric pressure
https://raphaelnussbaumer.com/GeoPressureR
GNU General Public License v3.0
7 stars 1 forks source link

`ï..species` when reading the csv file encoding #10

Closed Rafnuss closed 2 years ago

Rafnuss commented 2 years ago

Error when using flight_bird() on windows only

No match for 'Acrocephalus arundinaceus'. Please use the exact name. 
Closest matches are: 
[1] ï..species  wing_length secondary   mass       
<0 rows> (or 0-length row.names)
--- failed re-building 'wind-graph.Rmd'

Which comes from reading the csv file "avonet_clements.csv": https://github.com/Rafnuss/GeoPressureR/blob/d7c6e918dca60694027332dfe5b5ef232e8fbb6b/R/flight.R#L38-L40

This is apparently a common issue with UTF-8-BOM encoding.

Rafnuss commented 2 years ago

First tried to solved this with https://github.com/Rafnuss/GeoPressureR/blob/8b369bbe245c82d4bedc57e612a4ee6b25d64ec4/R/flight.R#L38-L40 But it didn't worked

Error in read.table(file = file, header = header, sep = sep, quote = quote,  : 
  no lines available in input
In addition: Warning message:
In file(file, "rt") :
  file("") only supports open = "w+" and open = "w+b": using the former

The second solution was to manually correct if afterward: https://github.com/Rafnuss/GeoPressureR/blob/b9b6f2dfc8583e4911c4b255f5b0a45ae4823775/R/flight.R#L41 But it wouldn't pass the check with the symbol, so resolved it by simply removing the character in GitHub editor directly: https://github.com/Rafnuss/GeoPressureR/commit/b9b6f2dfc8583e4911c4b255f5b0a45ae4823775