mod_import_csv

Module which adds “import CSV” button to the admin status screen.

The dropbox folder of the site is also watched for CSV or XLSX files.

To determine whether it can import a file, it uses a notification:

#import_csv_definition{basename, filename}

If the notification is not returning anything, it tries to map the columns found in the first row of the CSV file to resource column names. CSV/XLSX import module for admin-driven and watched-folder data imports.

Edge import

CSV files whose first three columns are subject, predicate, and object are imported as edge definitions instead of resources. The values in those columns are looked up as resource names: subject and object must name existing resources, and predicate must name an existing predicate resource.

An optional fourth column named order sets the edge sequence number. For example, a tab-separated file can contain:

subject predicate object  order
page_a  author    person_a 1

The separator can be a tab or comma, depending on what is detected for the file.

Resource rows can also define edges by using column names that start with > or <. The text after the marker is the predicate name, and the cell value is the resource name on the other side of the edge.

  • > author creates an outgoing edge from the imported row resource to the resource named in the cell.

  • < relation creates an incoming edge from the resource named in the cell to the imported row resource.

For example:

name   title    category  > author  < relation
page_b Page B   text      person_a   page_a

This creates page_b --author--> person_a and page_a --relation--> page_b.

Accepted Events

This module handles the following notifier callbacks:

  • observe_admin_menu: Add menu item to 'Content' admin menu using z_acl:is_allowed.

  • observe_dropbox_file: Import recognized CSV (including tab-separated) and XLSX files from the drop folder when an import definition matches.

Delegate callbacks:

  • event/2 with submit messages: csv_upload.

Edit on GitHub

Models

import_csv_data

Model to track resources imported from CSV and XLSX files.

Dispatch rules

dispatch

Dispatch rules Name Path Resource Args admin_import [“admin”,”import”] controller_admin [{template,”_admin_import.

Referred by

All dispatch rules

All the dispatch rules from all modules. For a background on dispatch rules, see The URL dispatch system.