ropensci / PostcodesioR

API wrapper around postcodes.io - free UK postcode lookup and geocoder
https://docs.ropensci.org/PostcodesioR
39 stars 7 forks source link

bulk_postcode_lookup does not ignore spaces #17

Open dave-lovell opened 7 months ago

dave-lovell commented 7 months ago

The help file for bulk_postcodes_lookup() says that spaces are ignored. Spaces are ignored for postcode_lookup(), but not for bulk_postcode_lookup().

library(PostcodesioR)

postcode_lookup("S7 1FL")
#>   postcode quality eastings northings country                   nhs_ha
#> 1   S7 1FL       1   434790    385119 England Yorkshire and the Humber
#>   longitude latitude european_electoral_region primary_care_trust
#> 1 -1.478695 53.36182  Yorkshire and The Humber          Sheffield
#>                     region           lsoa          msoa incode outcode
#> 1 Yorkshire and The Humber Sheffield 042D Sheffield 042    1FL      S7
#>   parliamentary_constituency admin_district                     parish
#> 1          Sheffield Central      Sheffield Sheffield, unparished area
#>   admin_county date_of_introduction              admin_ward ced
#> 1           NA               198001 Nether Edge and Sharrow  NA
#>                   ccg      nuts             pfa admin_district_code
#> 1 NHS South Yorkshire Sheffield South Yorkshire           E08000019
#>   admin_county_code admin_ward_code parish_code parliamentary_constituency_code
#> 1         E99999999       E05010875   E43000173                       E14001467
#>    ccg_code ccg_id_code  ced_code nuts_code lsoa_code msoa_code lau2_code
#> 1 E38000146         03N E99999999     TLE32 E01008112 E02001652 E08000019
#>    pfa_code
#> 1 E23000011

bulk_postcode_lookup(list(postcodes = c("S7 1FL")))
#> Warning in extract_results(r): Bad Request (HTTP 400).

bulk_postcode_lookup(list(postcodes = c("S7 1FL", "S71FL"))) |> 
  lapply(\(x) is.null(x[["result"]]))
#> [[1]]
#> [1] TRUE
#> 
#> [[2]]
#> [1] FALSE

Created on 2024-03-05 with reprex v2.1.0