FmpReader 0.30.3
dotnet add package FmpReader --version 0.30.3
NuGet\Install-Package FmpReader -Version 0.30.3
<PackageReference Include="FmpReader" Version="0.30.3" />
<PackageVersion Include="FmpReader" Version="0.30.3" />
<PackageReference Include="FmpReader" />
paket add FmpReader --version 0.30.3
#r "nuget: FmpReader, 0.30.3"
#:package FmpReader@0.30.3
#addin nuget:?package=FmpReader&version=0.30.3
#tool nuget:?package=FmpReader&version=0.30.3
FmpReader
A .NET library and command-line tool for reading FileMaker Pro database files directly. No FileMaker Pro, no ODBC driver, no running host.
FmpReader opens an .fp7 or .fmp12 file, walks its internal block chain, and exposes the database's shape and contents through a small, strongly typed API. It started as a port of the fmptools C library by Evan Miller and has since diverged from it, adding typed values among other changes. The CLI's --text mode still reproduces fmptools output (see Attribution).
Install
dotnet add package FmpReader
The library targets netstandard2.0, so it runs on .NET Framework 4.6.1+ and .NET Core 2.0+ (including .NET 10).
Build
dotnet build FmpReader.sln
dotnet test
The solution builds with TreatWarningsAsErrors=true.
Current limitations
- The first listing of tables walks the whole file. The reader streams the block chain in order: the first
ListTableswalks the whole chain and records which leaves belong to which table; later reads of one table visit only its leaves. Memory is a few tens of bytes per block. - No container data yet. Container blobs are not read; a container cell or global is delivered as its reference text.
- fp7 and fmp12 only. fp3/fp5, encrypted files, and unknown formats are rejected with
FmpException(UnsupportedFormat,EncryptedFile, orBadMagicNumber).
Library
Open a file
using FmpReader;
using var file = FmpFile.Open("Example.fmp12");
Console.WriteLine($"{file.FileName} — FileMaker {file.VersionString}");
Console.WriteLine($"Locale {file.Locale.DateOrder}, decimal '{file.Locale.DecimalSeparator}' ({file.LocaleSource})");
Open also accepts a seekable stream. The FmpFile keeps the stream open until it is disposed, so do not use or close a stream you passed in; copy a non-seekable source to a temp file and open that path instead.
using var file = FmpFile.Open(stream, "Example.fmp12");
An FmpFile is not thread-safe; open one per concurrent reader.
Options are read once, by Open:
var options = new FmpOpenOptions
{
Diagnostics = Console.Error,
NumberParsing = FmpNumberParsing.FileMakerDigits,
};
using var file = FmpFile.Open("Example.fmp12", options);
List tables and columns
foreach (var table in file.ListTables())
{
Console.WriteLine(table.Name);
foreach (var column in file.ListColumns(table))
Console.WriteLine($" {column.Index}: {column.Name} [{column.Type} {column.Kind}] x{column.MaxRepetitions}");
}
Read record values
ReadValues calls the handler once per stored repetition, in file order, and returns the walk's FmpError:
var error = file.ReadValues(table, cell =>
{
// Globals, summaries and unstored calculations can still hold a stale record value.
// Skip them when building a table from records.
if (!cell.Column.HasRecordValues)
return true;
Console.WriteLine($"{cell.Row} {cell.RecordId} {cell.Column.Name}[{cell.Repetition}] = {cell.Value.Text}");
return true; // false stops the walk and returns FmpError.UserAborted
});
if (error != FmpError.Ok)
Console.Error.WriteLine($"walk ended early: {error}");
cell.Row counts records from 1 in file order. cell.RecordId is FileMaker's record id, which stays the same when other records are deleted. A record with no stored values is never delivered, so it takes no Row. cell.Repetition is 1 for a non-repeating field. Empty cells and empty repetitions are not delivered, so reconstruct a grid by placing each value at (Row, Column.Index, Repetition):
var cells = new Dictionary<(int Row, int Column, int Repetition), object?>();
file.ReadValues(table, cell =>
{
cells[(cell.Row, cell.Column.Index, cell.Repetition)] = cell.Value.ToObject();
return true;
});
EnumerateValues yields the same cells lazily. Each foreach starts a fresh walk, and breaking out of the loop stops it without an exception:
foreach (var cell in file.EnumerateValues(table))
{
cells[(cell.Row, cell.Column.Index, cell.Repetition)] = cell.Value.ToObject();
}
On a walk error, ReadValues returns the code after delivering what it read, while EnumerateValues throws FmpException after yielding what it read, on every enumeration. Prefer ReadValues when you need the code without an exception.
Typed values
cell.Value.Text is always the value exactly as stored. cell.Value.Status says how it was interpreted:
| Status | Meaning |
|---|---|
Converted |
The text parsed as the column's type in the file's locale. Every value of a text column is Converted. |
Blank |
Empty or whitespace-only, in a non-text column. |
Unconverted |
The text did not parse, or the column type is unknown. |
Extracted |
A number read by FileMaker-style digit extraction (NumberParsing = FmpNumberParsing.FileMakerDigits). |
Read the typed value with Get<T>() (no boxing) or ToObject() (boxed). Both return null for a blank or unconverted value:
decimal? amount = cell.Value.Get<decimal>();
DateTime? created = cell.Value.Get<DateTime>();
TimeSpan? elapsed = cell.Value.Get<TimeSpan>();
object? value = cell.Value.ToObject();
Get<T>() supports decimal, DateTime and TimeSpan, and returns null for any other T. The Number, DateTime and Time properties expose the same values.
Read globals
Globals hold one value per file, not one per record, so ReadValues does not deliver them:
foreach (var global in file.ReadGlobals(table))
Console.WriteLine($"{global.Column.Name}[{global.Repetition}] = {global.Value.ToObject()}");
Each FmpGlobalValue has a Column, a 1-based Repetition, and a Value typed like a record value. A global that was never set in the saved file is absent from the list. ReadGlobals and ReadValues build their own FmpColumn objects, so match them to ListColumns output by Index, not by reference.
Errors
Open, ListTables, ListColumns and ReadGlobals throw FmpException, whose Code is the FmpError. Each has a non-throwing counterpart: TryListColumns and TryReadGlobals return the FmpError and hand back whatever was read before it; ReadValues returns the code; EnumerateValues throws. A block's parse error is reported on every walk over that block, not just the first.
API at a glance
| Member | Behavior |
|---|---|
FmpFile.Open(string path, FmpOpenOptions? options = null) |
Opens a file and reads its locale. Throws FmpException on failure. |
FmpFile.Open(Stream stream, string? fileName = null, FmpOpenOptions? options = null) |
Same, from a seekable stream. |
file.Locale, file.LocaleSource, file.NumberParsing |
The locale values are typed in, where it came from, and the number mode. |
file.ListTables() |
Tables in index order; throws FmpException on a walk error. |
file.ListColumns(table) |
Columns in index order; throws FmpException on a walk error. |
file.TryListColumns(table, out columns) |
Returns the walk's FmpError; columns holds what was read before it. |
file.ReadValues(table, handler) |
Returns the walk's FmpError after delivering values. Delivers stale values of columns whose HasRecordValues is false; skip them. |
file.EnumerateValues(table) |
Lazily yields the cells ReadValues delivers; break to stop. Throws FmpException after a walk error. |
file.ReadGlobals(table) |
Every stored global value; throws FmpException on a walk error. |
file.TryReadGlobals(table, out globals) |
Returns the walk's FmpError; globals holds what was read before it. |
FmpValueHandler(FmpCell cell) |
Called once per stored repetition; return true to continue or false to stop. |
FmpCell |
Row, RecordId, Column, Repetition (1-based) and Value. |
FmpGlobalValue |
Column, Repetition (1-based) and Value. |
FmpValue |
Type, Status, Text, Number, DateTime, Time, Get<T>(), ToObject(); ToString() is Text. Accessors return null instead of throwing. |
FmpException |
Code, the FmpError; the message is FileMaker file error: {Code}. |
FmpOpenOptions |
DefaultLocale, Diagnostics, NumberParsing, FmptoolsCompatibleText; all read once by Open. |
file.Diagnostics |
The TextWriter parser warnings go to, or TextWriter.Null. |
FmptoolsCompatibleText decodes names and values as fmptools does and, like it, reports a block's parse error only on the first walk over it. The CLI sets it for --text and --audit --compat.
CLI: FileMaker to SQLite
Usage: FmpReader.Cli [--text | --audit [--compat]] [--filemaker-digits] [input file] [output file]
dotnet run --project src/FmpReader.Cli -- Example.fmp12 Example.sqlite
The flags may come in any order, before or after the two paths, and each may appear once. An unknown flag, a repeated flag, --text with --audit, --compat without --audit, or anything other than two paths prints the usage line to stdout and exits 1. Progress (CREATE TABLE "...") goes to stderr. The exit code is 0 on success; if a table cannot be created, for example one with no columns, the tool exits 1 and leaves the tables already written.
| Mode | Output |
|---|---|
| default | Typed SQLite. Faithful text, table names and column names. |
--text |
The fmptools fmp2sqlite database, byte for byte: every column TEXT, every value the fmptools-compatible string, repetitions joined by U+001D. |
--audit |
A UTF-8 TSV, one line per delivered value, with faithful text. |
--audit --compat |
The same TSV with fmptools-compatible text and names. |
--filemaker-digits |
Opens with FmpNumberParsing.FileMakerDigits; changes the typed output and the audit only where strict parsing leaves a number unconverted. No effect under --text. |
Typed SQLite
Every table is created STRICT, so SQLite never converts a value to REAL. Column names have spaces replaced by _, as in --text, and a " in a table or column name is doubled. Two names that become equal after that, or that differ only in ASCII case, still make CREATE TABLE fail with exit 1. Text holding U+0000 is stored whole.
| Column | Declared | Stored |
|---|---|---|
| Number | ANY |
INTEGER when the value converts, is integral and fits a 64-bit integer. Any other converted number is TEXT holding the exact decimal in invariant form with its scale (31.8750, 0.57999999999999996). An unconverted value is TEXT holding the text as stored. |
| Date | TEXT |
yyyy-MM-dd |
| Timestamp | TEXT |
yyyy-MM-dd HH:mm:ss, plus .fffffff when the time has a fraction of a second |
| Time | TEXT |
[-]H:mm:ss, with hours unbounded and .fffffff when there is a fraction of a second |
| Text, unknown type | TEXT |
The text as stored |
| Container | ANY |
The reference text as stored |
Repeating (MaxRepetitions > 1) |
TEXT |
The repetitions' text joined by U+001D, as in --text |
No record values (HasRecordValues false) |
as its type | Always NULL |
A blank value (empty or whitespace only, in a non-text column) is NULL. A date, time or timestamp that does not convert is stored as its text. A cell that receives more than one repetition, or a repetition above 1, holds the U+001D-joined text exactly as --text writes it, even in a column declared with one repetition. When a cell receives two values of the same repetition, the later one is kept, as in --text. Every record still gets a row, even one whose only values are in columns without record values.
After the last table, the typed output adds one more table, _fmp_globals, with one row per stored repetition of every global field, table by table in file order:
CREATE TABLE "_fmp_globals" ("table" TEXT, "column" TEXT, "repetition" INTEGER, "value" ANY) STRICT;
table is the table name, and column is the column name as the typed table declares it, with spaces replaced by _. value is stored by the typed mapping above, by the global column's type; repetitions are separate rows, never joined. The table is always created, even when the file has no globals. A run that stops at a table it cannot create (exit 1) never reaches it. If the file has a table of its own named _fmp_globals (in any letter case), creating it fails, and the tool prints Error creating SQL table: ... and exits 1, with every FileMaker table already written. --text writes no _fmp_globals.
Audit TSV
Every line ends with LF, and its fields are separated by tabs. Split lines on LF (0x0A) only, never with Python's str.splitlines(): U+0085, U+2028 and U+2029 are written raw inside text. In the text fields (names, locale strings, and text), backslash is written \\, tab \t, LF \n, CR \r and U+0000 \0. Every other code point from U+0001 to U+001F, and U+007F, is written \x and two lowercase hex digits, for example \x1d. Everything else is written as UTF-8. The file starts with a header block:
| Line | Fields after the kind |
|---|---|
T |
faithful or compat |
N |
Strict or FileMakerDigits |
K |
the locale: source (File, Option, Default), date order (MonthDayYear, DayMonthYear, YearMonthDay), decimal separator, thousands separator, date separator, time separator, AM designator, PM designator, currency symbol (all four untrimmed), language code |
D |
one per table, in ListTables order: table index, table name |
L |
one per column, after its table's D line: table index, column index, name, type, kind, IsGlobal, IsStored, HasRecordValues, IsIndexed (each 0 or 1), the AutoEnter bits as a decimal integer, MaxRepetitions |
Then comes one V line per delivered value, table by table, in callback order. After every table's V lines come the G lines, table by table, one per value that ReadGlobals returns, in its order:
V table_index row record_id column_index repetition type status typed text
G table_index (empty) (empty) column_index repetition type status typed text
A G line has the same ten fields as a V line, with row and record_id empty, since a global belongs to no record. type is the FmpColumnType name. status is C (Converted), X (Extracted), B (Blank) or U (Unconverted). typed is a converted or extracted number as decimal.ToString(CultureInfo.InvariantCulture), scale kept (12.00, 0.00001), and a date, time or timestamp in the typed-SQLite forms above. For an integral number within 64 bits it equals the typed SQLite INTEGER numerically, not textually. It is empty for B, for U, and for text values. Values of columns without record values are written as delivered. A table with no columns has a D line and no L lines, and the audit continues past it. The walk's error code is not recorded. If the output cannot be created, the tool prints Error opening audit file and exits 1. If a write fails, it prints Error writing audit file and exits 1.
Attribution
FmpReader started as a port of fmptools by Evan Miller, at commit 2738719, and has since diverged from it. The test fixtures under test/fixtures/ come from the fmptools corpus and are used under the MIT license, except fmp12/digits.fmp12 and fmp12/values.fmp12, which were built for this project.
License
This project is released under the MIT License. Third-party notices are listed in THIRD-PARTY-NOTICES.md.
| 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 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. 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.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.30.3 | 149 | 10/16/2026 |