Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

CSV Serialization

Security covered Under active development 91,822 sites

This module adds support for the CSV file format to Drupal's data serialization system. It allows Drupal's REST module to send and receive data as CSV, and enables Views to export data in CSV format.

This module provides a CSV encoder for the Drupal Serialization API. This enables the CSV format to be used for data input and output in various circumstances. For example:

  • Drupal's REST module can accept or return data in CSV format
  • Views can output CSV data via a 'REST Export' view
  • Module developers may leverage CSV as a format when using the Serialization API

Requirements

You should use Composer to manage your Drupal site dependencies. This may require several modifications to your application's root composer.json. You must modify your composer.json in accordance with the linked documentation before following the installation instructions. Please read the documentation if you are not familiar with the specifics of managing a Drupal site with Composer.

Composer alternative

This module supports Ludwig, a manual alternative to managing Drupal modules with Composer.

Installation

  1. Download the csv_serialization module via Composer: composer require drupal/csv_serialization. This will only work if your Drupal application meets the requirements listed above. Alternatively, you may use Ludwig.
  2. Enable modules: rest, csv_serialization

How to create a CSV view

  1. Create a new view
  2. Add a "Rest Export" display to the view
  3. Check ONLY "csv" for Accepted request formats under Format -> Serializer -> Settings
  4. Set a path for the View display under Path Settings
  5. Change Format -> Show to "fields"
  6. Add fields to the view
  7. Verify that content exists which should be displayed in the view
  8. Save the view
  9. Visit the path that you set for the view
  10. A CSV file should be automatically downloaded when you visit the URL

Notes about the CSV encoder

The CSV format has a number of inherent limitations not present in other formats
(e.g., JSON or XML). Namely, they are:

  • A CSV cannot accurately represent the data in an array with a depth greater two. Cell contents must be flattened into a string, which at most represents single-dimensional imploded values.
  • Each row in a CSV must share a common set of headers with all other rows.

For these reasons, the CSV format is not well-suited for encoding all data structures--only data with a specific structure. The provided CSV encoder does not support data structures that do not meet these limitations.

Related Modules

  • Views Rest Feed permits a "Rest export feed" view display to be attached to another View display as a feed, in the same way that RSS feeds may be attached.
Drupal 10–11

Ask your assistant about CSV Serialization

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • serialization Drupal core

Required by

1 tracked project depends on this one

Activity

Tracked releases
8
Tracked since
Feb 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
4.0.1 Stable 10–11 Aug 12, 2024
4.0.0 Stable 10 Oct 30, 2023
3.0.1 Stable 9 Oct 30, 2023
4.x-dev Dev 10–11 Oct 30, 2023
3.0.0 Stable 10 Apr 18, 2023
3.0.0-rc1 Pre-release 10 Mar 15, 2023
3.0.0-beta2 Pre-release 10 Feb 24, 2023
3.0.0-beta1 Pre-release 9–10 Feb 23, 2023