Select sub column in asciidoctor CSV table to form new table.
Similar function
28.6.3 asciidoctor by-line-ranges
To include content by column range, begin with start column end with end column and separate them with two dot (e.g., columns=1..5) to the columns attribute.
include::filename.csv[columns=1..3, column_separator=","]
You could have multiple ranges separate with comma. Quote the list of ranges as commas are normally to separate individual attributes.
include::filename.csv[columns="1..3,10..14", column_separator=","]
You can use semi-colons to separate ranges to instead the quote and commas combination.
include::filename.csv[columns=1;5..8;10..15, column_separator=","]
column_separator in attribute need defined according filename.csv. if column separator is ";", change the value column_separator=";"
include::filename.csv[columns=1;5..8;10..15, column_separator=";"]
-
Original csv file
[%autowidth%header, format=csv, separator=,]
|===
include::{includedir}\FieldAgents.csv[]
|===
-
New csv file with choose sub column
[%autowidth%header, format=csv, separator=,]
|===
include::{includedir}\FieldAgents.csv[columns="1,4,5", column_separator=","]
|===
OR
[%autowidth%header, format=csv, separator=,]
|===
include::{includedir}\FieldAgents.csv[columns=1;4;5, column_separator=","]
|===
First, make sure Asciidoctor is installed:
$ gem install asciidoctor
Next, run the extension from the root directory of the project:
$ asciidoctor -r ./lib/csvsubcolumn-include-processor.rb ./sample.adoc
The output file, sample.html, was created in the same directory as the source file, sample.adoc.
The relevant bits of the input and output are shown below.
-
Column range: Refer to the last column of the document using the value -1.
include::filename.csv[columns=3..-1]
-
check edge case (file is empty, et al). Show fridendly information to user.
-
Use table attribute key "separator" [%autowidth%header, format=csv, separator=,] to replace include attribute key "column_separator".
There are some topic on this issue, such as:
-
Asciidoctor github issue #2101 asciidoctor/asciidoctor#2101
-
related topic Extension lab
textql-block
textql