DbfDataReader 1.0.0
dotnet add package DbfDataReader --version 1.0.0
NuGet\Install-Package DbfDataReader -Version 1.0.0
<PackageReference Include="DbfDataReader" Version="1.0.0" />
<PackageVersion Include="DbfDataReader" Version="1.0.0" />
<PackageReference Include="DbfDataReader" />
paket add DbfDataReader --version 1.0.0
#r "nuget: DbfDataReader, 1.0.0"
#:package DbfDataReader@1.0.0
#addin nuget:?package=DbfDataReader&version=1.0.0
#tool nuget:?package=DbfDataReader&version=1.0.0
DbfDataReader
DbfDataReader is a small fast .Net Core library for reading dBase, xBase, Clipper and FoxPro database files
Usage, to get summary info:
var dbfPath = "path\\file.dbf";
using (var dbfTable = new DbfTable(dbfPath, Encoding.UTF8))
{
var header = dbfTable.Header;
var versionDescription = header.VersionDescription;
var hasMemo = dbfTable.Memo != null;
var recordCount = header.RecordCount;
foreach (var dbfColumn in dbfTable.Columns)
{
var name = dbfColumn.ColumnName;
var columnType = dbfColumn.ColumnType;
var length = dbfColumn.Length;
var decimalCount = dbfColumn.DecimalCount;
}
}
and to iterate over the rows:
var skipDeleted = true;
var dbfPath = "path/file.dbf";
using (var dbfTable = new DbfTable(dbfPath, Encoding.UTF8))
{
var dbfRecord = new DbfRecord(dbfTable);
while (dbfTable.Read(dbfRecord))
{
if (skipDeleted && dbfRecord.IsDeleted)
{
continue;
}
foreach (var dbfValue in dbfRecord.Values)
{
var stringValue = dbfValue.ToString();
var obj = dbfValue.GetValue();
}
}
}
There is also an implementation of DbDataReader:
var options = new DbfDataReaderOptions
{
SkipDeletedRecords = true
// Encoding = EncodingProvider.GetEncoding(1252);
};
var dbfPath = "path/file.dbf";
using (var dbfDataReader = new DbfDataReader(dbfPath, options))
{
while (dbfDataReader.Read())
{
var valueCol1 = dbfDataReader.GetString(0);
var valueCol2 = dbfDataReader.GetDecimal(1);
var valueCol3 = dbfDataReader.GetDateTime(2);
var valueCol4 = dbfDataReader.GetInt32(3);
}
}
which also means you can bulk copy to MS SqlServer:
var options = new DbfDataReaderOptions
{
SkipDeletedRecords = true
// Encoding = EncodingProvider.GetEncoding(1252);
};
var dbfPath = "path/file.dbf";
using (var dbfDataReader = new DbfDataReader(dbfPath, options))
{
using (var bulkCopy = new SqlBulkCopy(connection))
{
bulkCopy.DestinationTableName = "DestinationTableName";
try
{
bulkCopy.WriteToServer(dbfDataReader);
}
catch (Exception ex)
{
Console.WriteLine($"Error importing: dbf file: '{dbfPath}', exception: {ex.Message}");
}
}
}
There is also an implementation of DbConnection so you can query a folder of files e.g.
var dbConnection = new DbfDbConnection(string.Empty, string.Empty);
dbConnection.ConnectionString = $"Folder=./test/fixtures;SkipDeletedRecords=false";
dbConnection.Open();
var dbCommand = dbConnection.CreateCommand();
dbCommand.CommandText = "select * from dbase_03.dbf;";
var reader = await dbCommand.ExecuteReaderAsync();
while (await reader.ReadAsync())
{
var valueCol1 = reader.GetString(0);
var valueCol11 = reader.GetDecimal(10);
}
The connection string supports the options available in DbfDataReaderOptions:
- Folder - the folder containing the files to be queried
- required
- string
- Encoding - the encoding to be used
- optional
- string
- valid Encoding name from Encoding
- ReadFloatsAsDecimals - whether to read floats as decimals
- optional
- boolean
- defaults to false
- SkipDeletedRecords - whether to skip deleted records
- optional
- boolean
- defaults to true
- StringTrimming - string timming behaviour
- optional
- string
- defaults to 'None'
- one of 'None', 'Trim', 'TrimStart', 'TrimEnd'
Used by
DbfBulkCopy
Command line application to bulk copy from DBF files to MS SqlServer
dbf
Command line utility to display DBF info and contents
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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 is compatible. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- System.Text.Encoding.CodePages (>= 10.0.3)
-
net10.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on DbfDataReader:
| Package | Downloads |
|---|---|
|
SwagOverFlow.Data
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 393 | 2/23/2026 |
| 0.9.0 | 202,668 | 6/12/2023 |
| 0.8.0 | 81,494 | 7/5/2021 |
| 0.7.0 | 34,558 | 2/19/2021 |
| 0.6.0 | 1,702 | 2/19/2021 |
| 0.5.8 | 8,449 | 2/18/2021 |
| 0.5.7 | 1,235 | 2/18/2021 |
| 0.5.6 | 2,478 | 2/16/2021 |
| 0.5.5 | 1,346 | 2/16/2021 |
| 0.5.4 | 227,484 | 3/2/2020 |
| 0.5.3 | 14,814 | 2/17/2020 |
| 0.5.2 | 108,061 | 11/20/2018 |
| 0.5.1 | 4,398 | 10/9/2018 |
| 0.5.0 | 2,499 | 9/25/2018 |
| 0.4.3 | 2,557 | 9/3/2018 |
| 0.4.1 | 10,207 | 11/27/2017 |
| 0.4.0 | 2,781 | 12/13/2016 |
| 0.3.0 | 2,298 | 12/13/2016 |
| 0.1.0-alpha-0008 | 1,838 | 12/13/2016 |