How to Change CSV Export Delimiter

Overview

Would you like to change the CSV export delimiter from a comma to something else? WPForms makes this super simple and all you need is a bit of PHP. This tutorial will walk you through how you would change the default , to something else for exporting your form entries.

By default, CSV exports of WPForms entry data will be separated by a comma. However, some systems that accept CSV data may require an alternate delimiter format.

Setup

In the example below, we’ll be modifying the CSV separator symbol to be a semicolon instead of a comma.

To add this snippet to your site, you can review this documentation.

For the purpose of this specific snippet, we recommend that you add the snippet by either creating a site-specific custom plugin or using the Insert Headers and Footers – Code Snippets by WPCode plugin as mentioned in this documentation.

/**
 * Filters the delimiter used in CSV exports of form entries.
 * 
 * @link https://wpforms.com/developers/change-csv-export-delimiter/
 */

function wpf_dev_pro_admin_entries_export_configuration( $configuration ) {

	$configuration[ 'csv_export_separator' ] = ';';

        return $configuration;

}

add_filter( 'wpforms_pro_admin_entries_export_configuration', 'wpf_dev_pro_admin_entries_export_configuration', 10, 1 );

Changing the CSV delimiter from a comma to a semicolon

And that’s it! You’ve successfully changed the delimiter! Would you like to know how to display a count of how many visitors have completed your form? Take a look at our article on How to Display Entry Submissions Count for a Specific Form.

Filter reference: wpforms_pro_admin_entries_export_configuration

FAQ

Q: Can the export data for an address be on separate lines?

A: Absolutely! Certain fields such as Address, Checkbox, and Likert Scale you can force the export to show each option on a new line by using this code.

/**
 * Filters the delimiter used in CSV exports of form entries.
 * 
 * @link https://wpforms.com/developers/change-csv-export-delimiter/
 */

function wpf_dev_pro_admin_entries_export_ajax_get_data( $export_data, $request_data ) {
 
         array_walk(
         $export_data,
         static function( &$row ) {
            $row = str_replace( "\n", ' ', $row );
         }
      );
 
    return $export_data;
 
}
add_filter( 'wpforms_pro_admin_entries_export_ajax_get_data', 'wpf_dev_pro_admin_entries_export_ajax_get_data', 10, 2 );

Q: Why doesn’t it separate the Address fields?

A: The address field is considered 1 form field so it would be shown as a single field in the export.