The Feeds Tamper module is an extension of the Feeds module that allows you to modify data before it's saved to Drupal entities. It provides a range of built-in plugins to manipulate data such as trimming text, converting case, performing calculations, and even custom PHP transformations. This is especially useful when dealing with messy or inconsistent data from external sources.
Feeds Tamper is a must-have tool for anyone who regularly imports content into Drupal from third-party sources.
Features and Benefits
Key Features
- Data Transformation Plugins: Modify data during the import process with plugins such as Find/Replace, Trim, and Case Conversion.
- Flexible Rules: Apply transformation rules to specific fields.
- Extendable: Developers can create custom plugins to fit unique use cases.
- UI Integration: Seamlessly integrates with the Feeds module for an intuitive experience.
Benefits
- Time-Saving: Automates data cleansing and preparation, reducing manual editing post-import.
- Data Consistency: Ensures that imported content adheres to your site's formatting standards.
- Flexibility: Works with various entity types including nodes, users, and taxonomy terms.
How to Configure Feeds Tamper
- Navigate to Feeds Importer:
Go toAdmin > Configuration > Web services > Feeds
and select your importer. - Add a Feeds Tamper Processor:
- Click on your importer and go to the Tamper tab.
- Click Add Tamper Plugin.
- Select a plugin from the list (e.g., Trim, Replace, or Case Conversion).
- Configure the Plugin:
- After selecting a plugin, configure its options based on your needs. For example:
- Trim: Remove whitespace from the beginning and end of strings.
- Replace: Find and replace specific text in the imported data.
- Choose the field where the tamper action should be applied.
- After selecting a plugin, configure its options based on your needs. For example:
- Save the Configuration:
- Once all tamper plugins are configured, save your importer.
How to Use Feeds Tamper
- Create or Edit an Importer:
Create a new Feeds importer or edit an existing one. Ensure Feeds Tamper is enabled. - Run the Importer:
Upload your CSV or XML file via the Feeds importer. - Review Imported Content:
Check that the data has been modified according to the tamper rules you set.
Best Practices
- Use Descriptive Tamper Plugin Names: Name your tamper plugins descriptively to understand their purpose easily.
- Test Tamper Rules Before Full Import: Always test your import on a smaller data set to avoid issues with large-scale imports.
- Combine Plugins for Complex Transformations: Use multiple tamper plugins in sequence for advanced data manipulation.
Use Case Scenarios
1. Cleaning Up Titles in Product Imports
Scenario: A store imports product data from a third-party supplier, but product titles come with unnecessary spaces and inconsistent casing.
Solution: Use the Trim plugin to remove whitespace and the Case Conversion plugin to standardize titles to Title Case.
2. Normalizing Email Addresses for User Imports
Scenario: A Drupal site imports users from an external CRM system. The email addresses are in a mix of uppercase and lowercase letters.
Solution: Apply the Lowercase plugin to ensure all email addresses are saved in lowercase for consistency.
3. Replacing Placeholder Text in Imported Articles
Scenario: An external content provider uses "Lorem Ipsum" as a placeholder in article bodies.
Solution: Use the Find/Replace plugin to remove or replace "Lorem Ipsum" with a relevant message or content.
Final Thoughts
The Feeds Tamper module is a powerful tool for cleaning and transforming imported data in Drupal. By configuring tamper plugins, you can automate data cleansing and ensure your site maintains high-quality, consistent content.