Each column type in Fuse has built-in transformations available. You refer to the documentation of a specific column type to see the available options.

When the built-in transformations are not enough for you, you can create your own custom data transformations using the formatRecord hook.

formatRecord(record)

The formatRecord hook is called for every row in the importer. It allows you to auto-format, correct issues, and more.

Here are some samples of things you might want to do with this hook:

  • Combine “first_name” and “last_name” into a “full_name” column.
  • Capitalize all of the values in a column.
  • Prepend “https://” to all of the URLs in a column.

The record passed to this hook is an object that represents a single row in the importer. You can access the properties of the record using the internal_key of each column.

Example

importer.formatRecord = (record) => {
  const newRecord = { ...record };

  // capitalize the first letter in first_name
  if (typeof newRecord.first_name === "string") {
    newRecord.first_name =
      newRecord.first_name.charAt(0).toUpperCase() +
      newRecord.first_name.slice(1);
  }

  return newRecord;
};