How to Use the Drupal Feeds and Feeds Tamper Modules for Easy CSV Data Imports
Tags: drupal, csvimport, feedsmodule
Published: 2023-05-11 02:12:26

---
title: How to Use the Drupal Feeds and Feeds Tamper Modules for Easy CSV Data Imports
published: true
date: 2023-04-29 16:57:33 UTC
tags: Drupal,CSVImport,CSVimport,Feedsmodule
canonical_url: https://davidloor.com/2023/04/29/how-to-use-the-drupal-feeds-and-feeds-tamper-modules-for-easy-csv-data-imports/
---

![Drupal feeds and feeds tamper modules](https://i0.wp.com/davidloor.com/wp-content/uploads/2023/04/drupal-feeds-feeds-tamper-modules-banner.png?resize=800%2C419&ssl=1)

The Feeds module in Drupal 9 is a powerful tool for importing external data into your Drupal website. It supports a variety of formats, including CSV, XML, and JSON, and can import content into nodes, taxonomies, and other entities in your Drupal site. To enhance the importing process, you can use the Feeds Tamper module, which allows you to modify data before it is saved. This tutorial will walk you through the process of using the Feeds module along with Feeds Tamper to import data from a CSV file.

1. Required modules:
  - Install and enable the following modules:
    - [Feeds](https://www.drupal.org/project/feeds)
    - [Feeds Tamper](https://www.drupal.org/project/feeds_tamper)
2. Create a content type:
  - If you don’t already have one, create a content type for the data you want to import from the CSV file.

![Add content type](https://i0.wp.com/davidloor.com/wp-content/uploads/2023/04/Screenshot-2023-04-29-at-9.03.08-AM.png?resize=683%2C321&ssl=1)

1. Set up a Feeds Importer:
  - Go to `Structure > Feeds types`
  - Click on `Add feed type`
  - Enter a name and description for your importer

![](https://i0.wp.com/davidloor.com/wp-content/uploads/2023/04/save-feed-type-1.jpg?resize=800%2C259&ssl=1)
_Create a new Feed Type_

![](https://i0.wp.com/davidloor.com/wp-content/uploads/2023/04/Screenshot-2023-04-29-at-11.46.57-AM.png?resize=800%2C303&ssl=1)
_Basic settings for the new feed_

1. Configure the Fetcher: 
  - Click on the “Fetcher” dropdown, and choose how you’d like to fetch the file. For this tutorial, use `Upload File` to manually upload the CSV file. Refer to the Fetcher a. and b. images below.

  - 

![](https://i0.wp.com/davidloor.com/wp-content/uploads/2023/04/Screenshot-2023-04-29-at-9.16.19-AM.png?resize=800%2C286&ssl=1)
_Fetcher a. Choose the Upload file fetcher_

![](https://i0.wp.com/davidloor.com/wp-content/uploads/2023/04/Screenshot-2023-04-29-at-11.20.28-AM-1.png?resize=800%2C404&ssl=1)
_Fetcher b. Fetcher settings_

1. Configure the **Parser** : 
  - Click on the “Parser” dropdown, choose `CSV`, and configure the appropriate CSV settings, like delimiter, No headers. The default settings will work for most of the use cases. Refer to the images below.

![](https://i0.wp.com/davidloor.com/wp-content/uploads/2023/04/Screenshot-2023-04-29-at-9.16.06-AM.png?resize=800%2C288&ssl=1)
_Parser a. Choose the CSV Parser_

![](https://i0.wp.com/davidloor.com/wp-content/uploads/2023/04/Screenshot-2023-04-29-at-9.29.15-AM.png?resize=800%2C244&ssl=1)
_Parser b. Parser settings_

1. Configure the Processor: Click on the “Processor” dropdown and choose Node. Then, click on the “Content Type” dropdown, and choose the target content type, and configure additional settings like author and default language. The Processor dropdown allows you to choose the type of entity that will be created when importing data. Refer to the images below.

![](https://i0.wp.com/davidloor.com/wp-content/uploads/2023/04/Screenshot-2023-04-29-at-11.30.28-AM.png?resize=800%2C514&ssl=1)
_Processor a. Choose the processor_

![](https://i0.wp.com/davidloor.com/wp-content/uploads/2023/04/Screenshot-2023-04-29-at-11.36.06-AM.png?resize=800%2C499&ssl=1)
_Processor b. Choose the Content Type_

![](https://i0.wp.com/davidloor.com/wp-content/uploads/2023/04/Screenshot-2023-04-29-at-11.14.43-AM.png?resize=800%2C425&ssl=1)
_Processor b. Processor settings_

**Language** : This setting allows you to select the language for the imported content.

**Update existing content items** : This setting determines how existing content items are handled when new data is imported. You can choose to update existing content items, not update them, or replace them entirely. The module will use the unique mappings you have set up to determine which content items are considered “existing” and should be updated or replaced.

**Previously imported items** : This setting allows you to choose what to do with items that were previously imported but are no longer present in the feed. You can choose to keep them or take some other action.

**Expire content items** : This setting allows you to specify when content items should be deleted. You can choose to never delete them or set a specific time period after which they will be deleted.

**Owner** : This setting allows you to specify the owner of the imported content. You can choose to use the feed author as the owner or select a specific user. If you leave this field blank, the owner will be set as Anonymous.

1. Click on Save and add mappings

1. Map the source CSV fields to the target content type fields:
  - Click on the  **Mapping**  tab: This will take you to the mapping configuration page where you can map source data to target fields.
  - Map source CSV columns to the target content type fields by clicking  **Select a target** : This will allow you to select the target Drupal field that you want to map data to. Then, in the “Source” column, select **New CSV Source** and enter the name of the column from your CSV file that contains the data you want to map to the selected target field.

  - Optionally, configure unique fields to avoid duplicate imports: This allows you to specify which fields should be used to determine if an imported item is a duplicate of an existing item. If a duplicate is found, the module can be configured to update or replace the existing item.
  - Tweak other configurations like language handling: This allows you to configure additional settings for your importer, such as how language should be handled.
  - Click  **Save** : This will save your mapping and other configuration settings.

![](https://i0.wp.com/davidloor.com/wp-content/uploads/2023/04/Screenshot-2023-04-29-at-12.13.46-PM.png?resize=800%2C415&ssl=1)
_Map CSV fields to Drupal fields_

1. Import the data using the Feeds importer:
  - Go to `Content > Feeds importers`
  - Click on `Import` for the importer that you created previously
  - Upload your CSV file (If you configured file upload as your fetcher)
  - Click `Import`
  - The imported content should now appear as nodes of the target content type within your Drupal site `/admin/content`

## Use Feeds Tamper to manipulate imported data

The Feeds Tamper module is a contrib module for the Drupal Feeds module that allows you to modify data before it is imported. It provides a user interface for adding “tamper” plugins to the individual mapped fields of your Feeds importer, which can perform various data manipulation tasks such as splitting, combining, or rewriting data.

1. Confirm that the Feeds Tamper module is enabled.
2. Go to the configuration page for your feed importer: Navigate to the configuration page for the feed importer that you want to use with the Feeds Tamper module. You can do this by going to the “Structure” page, then clicking on “Feeds” and selecting the importer you want to configure.
3. Click on the “Tamper” tab: On the configuration page for your feed importer, click on the “Tamper” tab to access the tamper settings.
4. Add tamper plugins to mapped fields: In the tamper settings table, find the mapped field to which you want to add a tamper plugin to. In the “Plugin” column for that field, click on the “Add plugin” button. Select the plugin you want to use from the list of available plugins, then configure its settings as needed.
5. Save your changes: Once you have added and configured all of the tamper plugins you want to use, click on the “Save” button to save your changes.
6. Repeat these steps for all the source columns you want to modify before storing the data

### Feeds tamper module’s use cases

- **Data cleanup** : You can use the Feeds Tamper module to clean up data before it is imported. For example, you can use the “Find and replace” plugin to replace specific words or phrases in your data.
- **Data transformation** : You can use the Feeds Tamper module to transform data before it is imported. For example, you can use the “Explode” plugin to split a single field into multiple values, or the “Implode” plugin to combine multiple fields into a single value. The “Explode” plugin is useful when mapping multiple comma-separated fields from the CSV file to a taxonomy reference field. 
- **Data filtering** : You can use the Feeds Tamper module to filter data before it is imported. For example, you can use the “Keyword Filter” plugin to only import items that contain specific keywords.
- **Data rewriting** : You can use the Feeds Tamper module to rewrite data before it is imported. For example, you can use the “Rewrite” plugin to change the format of dates or numbers in your data, or the “Pathauto” plugin to automatically generate URL aliases for imported content.

And that’s it! You have successfully configured the Feeds module in Drupal 9 to import and manipulate data from a CSV file using the Feeds Tamper module.