Text to CSV export, what is your favourite approach?

In order of preference:

  1. Record export and let FileMaker handle the complexity for me;
  2. Use a calculation field to generate the record data then export that field in a tab-delimited file;
  3. Use a calculation field to generate the record data, collate the data then export the field data to file;
  4. Use a calculation field to generate the record data, collate the data then write the data to file.

I will skip 1 when I need a field separator other than comma.

A little more info on the CSV file format…

I've written CSV exporters and parsers in C. CSV rules are simple. They allow for a lot:

  1. The file contains only text;
  2. The field separator can be anything;
  3. The record separator can be CR, LF or CR-LF;
  4. Data NEEDS to be double-quote encapsulated ONLY if the field or record separator is present in the data.

There is no prescribed escaping mechanism. The most common escape mechanisms I know of is the doubling of double-quotes. I have also seen the C-style escape mechanism.

There is no allowance for non-record data, therefore no meta-data or field names. The fact some applications allow you to export field names as the first record can cause problems with importers that view all records as data.

Hope this helps.

1 Like