Features
Initially based on Views JSON Source, this module is an extension of the Views module designed to work with data stored in a comma-separated value (CSV) file. The file can be uploaded or hosted on a remote server. The module provides a way to read the data from the CSV file and display it in any of the formats available through Views. The module also provides a way to filter and sort the data using the Views module. It's great for making tables and charts from an existing CSV file and not having to enter the data into an entity.
Why Use This Module?
There are several reasons you may want to use this module:
- You want the power of Views to view data, but you don't want to create a new content type or entity to store the data. This could be because the data do not fit with your site's content model, or because you don't want to create a new content type for a one-off use case.
- You want to connect to a data source that's not already within your site and is not in a database or easily accessible through an API.
- The amount of data you want to display at once is too large for Views to handle (in our experience, Views can rarely handle more than a few hundred rows of data at once).
Post-Installation
When creating a View, choose "CSV" in the "Show" field. On the "Edit View" page, in the "Advanced" section, find the "Query settings" section and click the "Settings" link. Inside the modal, you must enter a link to the CSV file. It can either be a link to a file within your filesystem or a link to a file sitting on a different server. Links that do not have a .csv extension will work as long as the file generated by the link is a CSV file. If you need authentication to access the file, you can pass headers like this: {"Authorization":"Basic xxxxx","Content-Type":"application/csv"} where xxxxx is the base64 encoded username and password.
After applying the settings, you can proceed to select the columns you want to display in the view, with each column being represented by a field in the view. All of your columns will use the same field plugin, which has the title: "CSV Field". Inside the settings for the field, you can choose the column you want to display using the "Column Selector" dropdown.
Like with other Views fields, you can rewrite the output of the field, add custom classes, and even use the values with other field plugins, such as the one provided by the contributed module Views Simple Math Field.
There are two types of filters available: "CSV Field" and "CSV Field Options". The "CSV Field" filter is a typical text filter. The "CSV Field Options" filter provides a dropdown that is populated with the unique values from the selected column (sorted). If your column has more than one option in a cell, you can select a separator in the filter settings and click "Refresh value options" to update the dropdown values. Both of these filters can be exposed.
The module also comes with a sort and a contextual filter plugin.
Similar projects
Supporting this Module
If you would like to support development of this module, please consider funding us through our Open Collective: https://opencollective.com/drupal-charts