+}
+
+static void
+csv_output_table_layer (struct csv_driver *csv, const struct pivot_table *pt,
+ const size_t *layer_indexes)
+{
+ struct table *title, *layers, *body, *caption, *footnotes;
+ pivot_output (pt, layer_indexes, true, &title, &layers, &body,
+ &caption, &footnotes, NULL, NULL);
+
+ csv_put_separator (csv);
+ csv_output_table__ (csv, pt, title, "Table");
+ csv_output_table__ (csv, pt, layers, "Layer");
+ csv_output_table__ (csv, pt, body, NULL);
+ csv_output_table__ (csv, pt, caption, "Caption");
+ csv_output_table__ (csv, pt, footnotes, "Footnote");
+
+ table_unref (title);
+ table_unref (layers);
+ table_unref (body);
+ table_unref (caption);
+ table_unref (footnotes);
+}
+
+static void
+csv_submit (struct output_driver *driver,
+ const struct output_item *item)
+{
+ struct csv_driver *csv = csv_driver_cast (driver);
+
+ switch (item->type)