NovikovRoman / godbf

A pure Go library for reading and writing dBase/xBase database files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

godbf

GoDoc Go Report Card Build Status

This fork from LindsayBradford/go-dbf has been heavily refactored and changed.

A pure Go library for reading and writing dBase/xBase database files.

You can incorporate the library into your local workspace with the following 'go get' command:

go get github.com/NovikovRoman/godbf

Code needing to call into the library needs to include the following import statement:

import (
  "github.com/NovikovRoman/godbf"
)

Here is a very simple snippet of example 'load' code to get you going:

  dbfTable, err := godbf.NewFromFile("exampleFile.dbf", nil)

  exampleList := make(ExampleList, dbfTable.NumberOfRecords())

  for i := 0; i < dbfTable.NumberOfRecords(); i++ {
    exampleList[i] = new(ExampleListEntry)

    exampleList[i].someColumnId, err = dbfTable.FieldValueByName(i, "SOME_COLUMN_ID")
  }

With encoding:

  dbfTable, err := godbf.NewFromFile("exampleFileCp866.dbf", charmap.CodePage866)

  exampleList := make(ExampleList, dbfTable.NumberOfRecords())

  for i := 0; i < dbfTable.NumberOfRecords(); i++ {
    exampleList[i] = new(ExampleListEntry)

    exampleList[i].someColumnId, err = dbfTable.FieldValueByName(i, "SOME_COLUMN_ID")
  }

Further examples can be found by browsing the library's test suite.

About

A pure Go library for reading and writing dBase/xBase database files

License:Apache License 2.0


Languages

Language:Go 100.0%