DBF (dbf_ex v0.1.0)

Read DBASE files in Elixir.

At the moment it only supports read.

Usage

Open a file with open/1 or open/2

  {:ok, db} = DBF.open("test/dbf_files/bayarea_zipcodes.dbf")

The resulting DB follows the enumerable protocol, so you can use all the functions in the Enum module.

So to get all the records of a database you can do:

  db |> Enum.to_list()

The result will be a tuple ´{status, %{...}}´ with the record status being either :record or :deleted_record.

You can get specific rows by using the DBF.get/2 function.

  case DBF.get(db, 2) do
    {:record, row} -> IO.inspect row
    {:deleted_record, row} -> IO.inspect row
    {:error, _} -> IO.puts "OMG"
  end

Summary

Functions

Closes the file access.

Get a record by number.

Open a DBase database file.

Same as open/2 but throws errors

Types

@type options() :: [{:memo_file, String.t() | nil}]

Functions

@spec close(DBF.Database.t()) :: :ok | {:error, atom()}

Closes the file access.

Link to this function

get(db, record_number)

@spec get(DBF.Database.t(), integer()) ::
  {:deleted_record, map()} | {:record, map()} | {:unknown, map()}

Get a record by number.

Link to this function

has_memo_file?(database)

@spec has_memo_file?(DBF.Database.t()) :: boolean()
Link to this function

open(filename, options \\ [])

@spec open(String.t(), options()) :: {:ok, DBF.Database.t()} | {:error, atom()}

Open a DBase database file.

Link to this function

open!(filename, options \\ [])

@spec open!(String.t(), options()) :: DBF.Database.t()

Same as open/2 but throws errors