Accessing specific entry in a CSV file in _data folder


I am unsure how to access data for a specific entry in a CSV file in my _data folder. Right now, my CSV looks like this:


I’d like to extract the corresponding ImageWidth and ImageHeight data for images I post. Something along these lines:

{% assign image =[FileName] %}

The data used in the examples in the Jekyll documentation page is formatted differently, and I am having a hard time figuring out how to go about this. I don’t have much flexibility in terms of how the data in the CSV is formatted, as it is being created by exiftool. Any guidance would be greatly appreciated.


ProTip™: Look at Jekyll’s feature tests if you look for examples

Use Jekyll’s inspect filter in your templates when developing to see how objects are formatted, it might help you know how to access them:

{{ | inspect }}

For example, you could write something like the following to display all images stored in your data file:

  {% for image in %}
      <img src="{{ image.path | relative_url }}/{{ image.filename }}" width="{{ image.width }}" height="{{ image.height }}" />
  {% endfor %}

You can access a specific entry either by user a where filter;

{{ | where:"filename","jekyll-search.png" }}

or by using its index: {{[0].filename }}