Top Contributors
-
matthewowen - 2
-
cnunciato - 2
-
LawrenceWoodman - 2
-
tsmango - 2
-
stereobooster - 2
Most Forked
- jekyll_alias_generator - 32
- jekyll-tagging - 30
- jekyll-scholar - 18
- jekyll-tweet-tag - 18
- jekyll-asset_bundler - 18
Most Watched
- jekyll-author-plugin - 10
- Simple-Jekyll-Search - 9
- jekyll-press - 9
- jekyll-scholar - 9
- jekyll_alias_generator - 8
Most Starred
- Simple-Jekyll-Search - 244
- jekyll-scholar - 176
- jekyll-tagging - 104
- jekyll_alias_generator - 102
- jekyll_indextank - 90
Plugin Information
jekyll-csv_read
Read data stored as CSV tables in the _csv directory and make it available to Jekyll
README.md
h1. Jekyll CSV Data Reader Plugin
This plugin makes data in csv tables available in "Jekyll":http://www.jekyll.com, similar to what "Jekyll":http://jekyllrb.com already does with YAML files.
h1. Installation
Download @read_csv.rb@ and put it in the @_plugins@ directory of your website.
h1. Usage
This plugin reads all csv files found in the @_csv@ directory and, for each file <
- @site.data.<
>.rows@ - @site.data.<
>.cols@ - @site.data.<
>.keys@ - @site.data.<
>.content@ - @site.data.<
>.content_hash@
where:
- @rows@ and @cols@ contain, respectively, the number of rows (without headers) and the number of columns of the table
- @keys@ is an array containing the header of the table
- @content@ is an array of arrays containing the table data
- @content_hash@ is an array of hashes, to access data using the columns names set in the header.
h1. Example
Suppose you have an @example.csv@ file stored in the @_csv@ directory of your Jekyll website, with the following content:
h1,h2,h3 a,b,c 1,2,3
Then, the following Jekyll template generates an HTML representation of the table:
--- title: Example ---
{{header}} | {% endfor %}
{{column}} | {% endfor %}
If you prefer to access cells using header names, you can use the @content_hash@ key. For instance, the following snippet extracts the content of column @h1@ and @h3@ from the table:
{% for row in site.data.example.content_hash %}{% endfor %} {{row.h1}} {{row.h3}}
See the @example@ directory for more details.
h1. Alternatives
Store the table data you want to access in @_data@, as a YAML file.
h1. Known Bugs
The plugin does not check for name clashes of files stored @_data@ and @_csv@ directory. Do not use the same name for files in @_data@ and @_csv@.
In other words, if you have a @_data/w.yaml@ file, do not create a @_csv/w.csv@ file.
h1. License
Distributed under the terms of the "MIT License":http://opensource.org/licenses/MIT