https://github.com/jongretar/dbfex
Read DBASE dbf files in Elixir.
https://github.com/jongretar/dbfex
database dbase dbf elixir-lang foxbase foxpro
Last synced: 4 months ago
JSON representation
Read DBASE dbf files in Elixir.
- Host: GitHub
- URL: https://github.com/jongretar/dbfex
- Owner: JonGretar
- Created: 2023-10-09T05:35:19.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-27T08:58:18.000Z (about 2 years ago)
- Last Synced: 2024-09-16T18:23:04.423Z (over 1 year ago)
- Topics: database, dbase, dbf, elixir-lang, foxbase, foxpro
- Language: Elixir
- Homepage:
- Size: 186 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DBF
Read DBASE files in Elixir.
At the moment it only supports read.
## Usage
Open a file with open/1 or open/2
```elixir
{: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:
```elixir
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.
```elixir
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
* http://independent-software.com/dbase-dbf-dbt-file-format.html
* https://www.clicketyclick.dk/databases/xbase/format/dbf.html#DBF_STRUCT
* https://wiki.dbfmanager.com/dbf-structure