DbfSharp.Core 0.1.7

There is a newer version of this package available.
See the version list below for details.
dotnet add package DbfSharp.Core --version 0.1.7
                    
NuGet\Install-Package DbfSharp.Core -Version 0.1.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DbfSharp.Core" Version="0.1.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DbfSharp.Core" Version="0.1.7" />
                    
Directory.Packages.props
<PackageReference Include="DbfSharp.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DbfSharp.Core --version 0.1.7
                    
#r "nuget: DbfSharp.Core, 0.1.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DbfSharp.Core@0.1.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DbfSharp.Core&version=0.1.7
                    
Install as a Cake Addin
#tool nuget:?package=DbfSharp.Core&version=0.1.7
                    
Install as a Cake Tool

DbfSharp

GitHub License

Yet another DBF file reader, but this one is mine. I built it primarily to make my own life easier. I often find myself needing to quickly peek into various .dbf files, validate their structure, or just export them to something more readable like CSV or JSON.

This project is split into two main parts:

  1. DbfSharp.Core: A high-performance, memory-efficient .NET library for reading DBF files.
  2. DbfSharp.Console: A cross-platform .NET command-line tool built on top of the core library.

Most people will probably just use the CLI tool.

The CLI Tool: dbfsharp

This is the quick and dirty way to get stuff done. For more detailed documentation, see the DbfSharp.Console README.

Installation

It's a .NET tool, so installation is a one-liner (perhaps I'll eventually add it to a brew tap or something, but for now, this is the easiest way):

dotnet tool install -g DbfSharp

Usage

Once installed, you can call it directly from your terminal.

1. Get info about a file:

This is great for a first look. It tells you the version, number of records, encoding, and field definitions.

dbfsharp info my_data.dbf

2. Read and display data:

You can dump the contents straight to your console. It defaults to a nice table view.

# Show the first 100 records in a table
dbfsharp read my_data.dbf --limit 100

# Select specific columns
dbfsharp read my_data.dbf --fields NAME,SALARY,EMAIL

3. Export to other formats:

You can pipe the output to a file or just view it directly.

# Export the whole file to CSV
dbfsharp read my_data.dbf --format csv > data.csv

# Quietly export 10 first rows to JSON
dbfsharp read my_data.dbf --limit 10 --format json --quiet > data.json

# You can even pipe data into it from stdin
cat my_data.dbf | dbfsharp read --format tsv

Supported formats: table, csv, tsv, json, and excel. Note that for Excel, you must specify an output file with --output.

Compatibility

The library aims to support a wide range of DBF formats. Here's a summary of the tested versions.

Version Description Version Byte Memo Support
dBase II dBASE II (pain in the !$#*) 0x02 None
dBase III Plus FoxBASE+/dBase III PLUS, no memo 0x03 None
dBase III Plus FoxBASE+/dBase III PLUS, with memo 0x83 .dbt
dBase IV dBASE IV with memo 0x8B .dbt
dBase IV SQL dBASE IV SQL table files, no memo 0x43 None
dBase IV SQL dBASE IV SQL table files, with memo 0xCB .dbt
FoxPro FoxPro 2.x (or earlier) with memo 0xF5 .fpt
Visual FoxPro Visual FoxPro 0x30 .fpt
Visual FoxPro VFP with autoincrement 0x31 .fpt
Visual FoxPro VFP with Varchar/Varbinary 0x32 .fpt

The Core Library: DbfSharp.Core

If you need to read DBF files from your own .NET application, you can use the core library directly. It's built with performance in mind, using modern .NET features like System.IO.Pipelines and Span<T>. For more detailed documentation, see the DbfSharp.Core README.

Quick Start

Here's a basic example of how to read records.

using DbfSharp.Core;

// Open the DBF file. By default, it streams records.
using var reader = DbfReader.Open("path/to/your/data.dbf");

foreach (var record in reader.Records)
{
    // Access fields by name (case-insensitive by default)
    var name = record.GetValue<string>("NAME");
    var birthDate = record.GetValue<DateTime?>("BIRTHDATE");
    var salary = record.GetValue<decimal?>("SALARY");

    Console.WriteLine($"{name}, born {birthDate:yyyy-MM-dd}, salary: {salary:C}");

    // Or access by index for a little extra speed
    var id = record[0];
}

Configuration

You can control the reader's behavior with DbfReaderOptions.

var options = new DbfReaderOptions
{
    // Load all records into memory for faster random access
    LoadOnOpen = true,

    // Don't throw an error if a .dbt or .fpt file is missing
    IgnoreMissingMemoFile = true,

    // Override the auto-detected encoding
    Encoding = System.Text.Encoding.GetEncoding("windows-1252")
};

using var reader = DbfReader.Open("data.dbf", options);

// Now you can access records by index because LoadOnOpen = true
var firstRecord = reader[0];
var lastRecord = reader[reader.Count - 1];

Why?

Honestly, I've used other DBF libraries and tools, but I wanted something that was:

  • Written in modern C# with a focus on performance.
  • Worked seamlessly across Windows, Linux, and macOS.
  • Had a simple, scriptable CLI that I could use in my daily workflow.
  • Was easy to extend if I ever came across a weird, non-standard DBF file.

This tool solves my problem. Maybe it will solve yours too.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.4 123 8/18/2025
0.2.3 208 8/6/2025
0.2.2 153 8/4/2025
0.2.1 53 8/1/2025
0.2.0 76 8/1/2025
0.1.7 136 7/30/2025