JonGretar / DBFex

Read DBASE dbf files in Elixir.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DBF

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

DBF File Format

About

Read DBASE dbf files in Elixir.


Languages

Language:Elixir 100.0%