+ putc ('\n', csv->file);
+ }
+}
+
+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 *output_item)
+{
+ struct csv_driver *csv = csv_driver_cast (driver);
+
+ if (is_table_item (output_item))
+ {
+ const struct pivot_table *pt = to_table_item (output_item)->pt;
+
+ size_t *layer_indexes;
+ PIVOT_OUTPUT_FOR_EACH_LAYER (layer_indexes, pt, true)
+ csv_output_table_layer (csv, pt, layer_indexes);