Read .dbf files

read_dbf(file, col_spec = "?", encoding = NA)

dbf_meta(file)

dbf_colmeta(file)

Arguments

file

A filename of a .dbf file.

col_spec

A character vector of length one with one character for each column or one character to be used for all columns. The following characters are supported (designed to align with readr::cols()):

  • "?": Use DBF-specified field type

  • "-": Skip column

  • "c": Character

  • "i": Parse integer

  • "d": Parse double

  • "l": Parse as logical

encoding

Use NA to automatically guess encoding, "" to use system encoding, or a length-one character vector overriding the automatically detected encoding.

Value

A tibble::tibble()

Examples

read_dbf(shp_example("mexico/cities.dbf"))
#> # A tibble: 36 x 4 #> NAME CAPITAL STATE_NAME POPULATION #> <chr> <chr> <chr> <dbl> #> 1 Monterrey Y Nuevo Leon 2015000 #> 2 Mazatlan N Sinaloa 199830 #> 3 Guadalajara Y Jalisco 2325000 #> 4 Tampico N Tamaulipas 435000 #> 5 Mexico City C Distrito Federal 14100000 #> 6 Puebla de Zaragoza Y Puebla 1055000 #> 7 Veracruz N Veracruz-Llave 385000 #> 8 Oaxaca Y Oaxaca 154223 #> 9 Merida Y Yucatan 400142 #> 10 Mexicali Y Baja California Norte 365000 #> # … with 26 more rows
dbf_meta(shp_example("mexico/cities.dbf"))
#> # A tibble: 1 x 4 #> file row_count field_count encoding #> <chr> <int> <int> <chr> #> 1 /Users/runner/work/_temp/Library/shp/shp/mexic… 36 4 NA
dbf_colmeta(shp_example("mexico/cities.dbf"))
#> # A tibble: 4 x 4 #> name type width precision #> <chr> <chr> <int> <int> #> 1 NAME C 51 0 #> 2 CAPITAL C 1 0 #> 3 STATE_NAME C 25 0 #> 4 POPULATION N 11 0