{"id":17223704,"url":"https://github.com/sebastiaanklippert/go-foxpro-dbf","last_synced_at":"2025-08-21T04:31:05.167Z","repository":{"id":57493236,"uuid":"42479292","full_name":"SebastiaanKlippert/go-foxpro-dbf","owner":"SebastiaanKlippert","description":"Golang package for reading XBase FoxPro DBF/FPT files","archived":false,"fork":false,"pushed_at":"2023-02-24T20:10:46.000Z","size":179,"stargazers_count":67,"open_issues_count":1,"forks_count":29,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-08-14T13:50:09.855Z","etag":null,"topics":["dbf","foxpro","fpt","go","golang","xbase"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SebastiaanKlippert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-09-14T21:55:16.000Z","updated_at":"2025-08-03T11:35:59.000Z","dependencies_parsed_at":"2023-01-31T03:01:00.482Z","dependency_job_id":"1d438538-e7d2-4b09-a926-36919fc15833","html_url":"https://github.com/SebastiaanKlippert/go-foxpro-dbf","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/SebastiaanKlippert/go-foxpro-dbf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebastiaanKlippert%2Fgo-foxpro-dbf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebastiaanKlippert%2Fgo-foxpro-dbf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebastiaanKlippert%2Fgo-foxpro-dbf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebastiaanKlippert%2Fgo-foxpro-dbf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SebastiaanKlippert","download_url":"https://codeload.github.com/SebastiaanKlippert/go-foxpro-dbf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebastiaanKlippert%2Fgo-foxpro-dbf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271425029,"owners_count":24757388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dbf","foxpro","fpt","go","golang","xbase"],"created_at":"2024-10-15T04:09:04.250Z","updated_at":"2025-08-21T04:31:04.855Z","avatar_url":"https://github.com/SebastiaanKlippert.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-foxpro-dbf\n\n[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](http://godoc.org/github.com/SebastiaanKlippert/go-foxpro-dbf)\n[![Build \u0026 test](https://github.com/SebastiaanKlippert/go-foxpro-dbf/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/SebastiaanKlippert/go-foxpro-dbf/actions/workflows/ubuntu.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/SebastiaanKlippert/go-foxpro-dbf)](https://goreportcard.com/report/github.com/SebastiaanKlippert/go-foxpro-dbf)\n[![codecov](https://codecov.io/gh/SebastiaanKlippert/go-foxpro-dbf/branch/master/graph/badge.svg)](https://codecov.io/gh/SebastiaanKlippert/go-foxpro-dbf)\n\nGolang package for reading FoxPro DBF/FPT files.\n\nThis package provides a reader for reading FoxPro database files.\nAt this moment it is only tested for Alaska XBase++ DBF/FPT files in FoxPro format and some\nolder FoxPro files, see the included `testdbf` folder for these files.\nThese files have file flag 0x30 (or 0x31 if autoincrement fields are present).\n\nSince these files are almost always used on Windows platforms the default encoding is\nfrom Windows-1250 to UTF8 but a universal encoder will be provided for other code pages.\n\n# Features \n\nThere are several similar packages but they are not suited for our use case, this package will try to implement:\n* Support for FPT (memo) files\n* Full support for Windows-1250 encoding to UTF8\n* File readers for scanning files (instead of reading the entire file to memory)\n\nThe focus is on performance while also trying to keep the code readable and easy to use.\n\n# Supported field types\n\nAt this moment not all FoxPro field types are supported.\nWhen reading field values, the value returned by this package is always `interface{}`. \nIf you need to cast this to the correct value helper functions are provided.\n\nThe supported field types with their return Go types are: \n\n| Field Type | Field Type Name | Golang type |\n|------------|-----------------|-------------|\n| B | Double | float64 |\n| C | Character | string |\n| D | Date | time.Time |\n| F | Float | float64 |\n| I | Integer | int32 |\n| L | Logical | bool |\n| M | Memo  | string |\n| M | Memo (Binary) | []byte |\n| N | Numeric (0 decimals) | int64 |\n| N | Numeric (with decimals) | float64 |\n| T | DateTime | time.Time |\n| Y | Currency | float64 |\n\n# Example\n\n```go\nfunc Test() error {\n\t// Open file\n\ttestdbf, err := dbf.OpenFile(\"TEST.DBF\", new(dbf.Win1250Decoder))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer testdbf.Close()\n\n\t// Print all the fieldnames\n\tfor _, name := range testdbf.FieldNames() {\n\t\tfmt.Println(name)\n\t}\n\n\t// Get fieldinfo for all fields\n\tfor _, field := range testdbf.Fields() {\n\t\tfmt.Println(field.FieldName(), field.FieldType(), field.Decimals /*etc*/)\n\t}\n\n\t// Read the complete second record\n\trecord, err := testdbf.RecordAt(1)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Print all the fields in their Go values\n\tfmt.Println(record.FieldSlice())\n\n\t// Loop through all records using recordpointer in DBF struct\n\t// Reads the complete record\n\tfor !testdbf.EOF() { // or for i := uint32(0); i \u003c testdbf.NumRecords(); i++ {\n\n\t\t// This reads the complete record\n\t\trecord, err := testdbf.Record()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\ttestdbf.Skip(1)\n\n\t\t// skip deleted records\n\t\tif record.Deleted {\n\t\t\tcontinue\n\t\t}\n\t\t// get field by position\n\t\tfield1, err := record.Field(0)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// get field by name\n\t\tfield2, err := record.Field(testdbf.FieldPos(\"NAAM\"))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfmt.Println(field1, field2)\n\t}\n\n\t// Read only the third field of records 2, 50 and 300\n\trecnumbers := []uint32{2, 50, 300}\n\tfor _, rec := range recnumbers {\n\t\terr := testdbf.GoTo(rec)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdeleted, err := testdbf.Deleted()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !deleted {\n\t\t\tfield3, err := testdbf.Field(3)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfmt.Println(field3)\n\t\t}\n\t}\n\n\treturn nil\n}\n```\n\n# Example using a byte reader\n\nYou can use OpenStream with any ReaderAt and ReadSeeker combo, for example a bytes.Reader.\nThe FPT stream is only required when the DBF header indicates there must be an FPT file.\n\n```go\nfunc TestBytes() error {\n\t\n\tdbfbytes, err := ioutil.ReadFile(\"TEST.DBF\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdbfreader := bytes.NewReader(dbfbytes)\n\n\tfptbytes, err := ioutil.ReadFile(\"TEST.FPT\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tfptreader := bytes.NewReader(fptbytes)\n\n\ttest_dbf, err = OpenStream(dbfreader, fptreader, new(Win1250Decoder))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer testdbf.Close()\n\n\t// Print all the fieldnames\n\tfor _, name := range testdbf.FieldNames() {\n\t\tfmt.Println(name)\n\t}\n\t\n\t// ETC...\n\t\n\treturn nil\t\n}\n```\n\n# Thanks\n\n* To [carlosjhr64](https://github.com/carlosjhr64) for the Julian date conversion package \u003chttps://github.com/carlosjhr64/jd\u003e\n* To [dkeza](https://github.com/dkeza) for submitting some issues and testing FoxPro files on 32 bit Go\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastiaanklippert%2Fgo-foxpro-dbf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebastiaanklippert%2Fgo-foxpro-dbf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastiaanklippert%2Fgo-foxpro-dbf/lists"}