Brian Dunning's FileMaker Custom Functions

TablesToCSV ( tableName, includeSummaryFields )

Exports one or all tables to a text string in valid CSV format

  Be the first to rate this function Log in to vote

Michael Kupietz   Michael Kupietz - Show more from this author
Michael Kupietz FileMaker Consulting
https://kupietz.com

  Sample input:
TablesToCSV( "", "")
  Sample output:
### TABLE: OneTable ###
"PrimaryKey","CreationTimestamp","CreatedBy","ModificationTimestamp","ModifiedBy"
"EAA2760B-D6AC-45F9-B19D-0AA73D1DAC95","2025-12-06 13:25:53","Admin","2025-12-06 13:25:54","Admin"
"FAE765F5-C9D9-471D-A12E-D6B361102AB2","2025-12-06 13:25:54","Admin","2025-12-06 13:25:54","Admin"
"FBAEADC8-DA0D-4E11-AF9F-61437BDDFD44","2025-12-06 13:25:56","Admin","2025-12-06 13:25:55","Admin"

### TABLE: AnotherTable ###
"PrimaryKey","CreationTimestamp","CreatedBy","ModificationTimestamp","ModifiedBy","ExtraField"
"3C4513F2-B617-4A5B-873F-D5983A23FD5C","2025-12-06 13:25:57","Admin","2025-12-06 13:25:55","Admin","extra value"
"A6CB7146-42A0-4C3E-AF8F-07A5348B7A17","2025-12-06 13:26:05","Admin","2025-12-06 13:25:55","Admin","2nd record extra value"
"3C9FADEF-56C7-49C1-B979-78BCE3E56E6E","2025-12-06 13:26:08","Admin","2025-12-06 17:59:26","Admin","3rd record extra value"

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

In response to a request on Reddit. A user was having problems copying the script out of Portage Bay's "Modular Export" demo for some unknown reason. This removes the need for a script, which can be difficult to copy if an error such as permissions problems prevents opening the Script Workspace.

By using a custom function, the solution can be pasted as text, directly into the Manage > Custom Functions... in any file.

This function creates a block of text containing a mock CSV export of a single table if the tableName parameter is specific, or of all tables if not. If it includes all tables, headers with the table names are included.

This provides a single table or the the full database in CSV format. Data can then be pasted into CSV files in a text editor.

Rather than prohibiting summary fields from the export, I have given the user the option to include them, and potentially freeze FileMaker, by specifying the includeSummaryFields parameter.

WARNING:
1. Even without including summary fields, running this on large tables may cause FileMaker to hang or crash due to memory limits. USE AT YOUR OWN RISK.
2. ExecuteSQL does not escape commas inside text data. Resulting CSVs are simple dumps. In practice, the author has not found this to be a concern when opening in Excel.

 

Comments

Michael Kupietz   Michael Kupietz, Michael Kupietz FileMaker Consulting
Dec 9, 2025
Tested working on a simple database. You may find edge cases where it fails.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 21 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: