Skip to content

Select sub column in asciidoctor CSV table to form new table

License

Notifications You must be signed in to change notification settings

ehmkah/Asciidoctor-CSV-SubColumn

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Asciidoctor-CSV-SubColumn

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=";"]

Example

  • Original csv file

[%autowidth%header, format=csv, separator=,]
|===
include::{includedir}\FieldAgents.csv[]
|===
README originalCSV
  • 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=","]
|===
README subCSV

Using extension

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.

./sample.adoc

sample.adoc

./sample.html

sample.html

TODO (Unfinished task)

  1. Column range: Refer to the last column of the document using the value -1.

include::filename.csv[columns=3..-1]
  1. check edge case (file is empty, et al). Show fridendly information to user.

  2. Use table attribute key "separator" [%autowidth%header, format=csv, separator=,] to replace include attribute key "column_separator".

Disscussions

There are some topic on this issue, such as:

About

Select sub column in asciidoctor CSV table to form new table

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 91.8%
  • Ruby 8.2%