Reference columns: Export CSV issue

Document with two tables:

  1. Classification
  2. Records

The Classification table has two columns:

  1. ref_number (an integer)
  2. name (text)

The Records table contains a Reference column to the Classifications table. In the Right Panel > Column > Show Column field Grist defaults to the Classification > name field. I change that setting to the Classification > ref_number field. Grist correctly shows the ref_number value in each Record row. Everything works as expected to this point.

However, with Export to CSV, the records.csv column for the classification reference contains this string: “Classifications[12345].” I want the integer in the csv file, the “12345” without the table name and brackets. As an aside, if I leave the default reference pointer to the name field, the csv just contains the name string, without table name and brackets. So the issues seems just related to changing the referenced column.

I have tried to use the Apply Formula to Data to use Python to return the correct result, but I only get errors or bad data in return.

The default entry for Apply Formula to Data is

return $Classification

I’ve tried accessing this as an object, as a dictionary, as a list with no success. Have I just got the syntax wrong or is there another feature I can use to get the result I’m after?

I do not want to add a second column (unless that is only option) with a formula because I have lots of these types of references so this solution would many duplicate columns.

Thanks,
Mark