Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read data files with same basename but different extensions #8300

Open
ShaneCurcuru opened this issue Jul 11, 2020 · 3 comments
Open
Labels

Comments

@ShaneCurcuru
Copy link

My Environment

Software Version(s)
Operating System OSX Catalina 10.15.5
jekyll Latest
github-pages Latest

Expected Behaviour

Given:
_data/samename.csv
_data/samename.json

I would expect that I could then access both data sources via site.data.samename.csv and site.data.samename.json (or some equivalent hash lookup similar to site.data['samename.json']).

Current Behavior

site.data.samename (or variants) only returns the contents of the .csv file. The .json file is not accessible at all.

Code Sample

The behavior is presumably because while data_reader.rb reads all data files, it indexes them by File.basename, meaning that any same-basenamed files will always only show data from the file with (presumably) the extension that happens to be last in the Dir glob here:

https://github.com/jekyll/jekyll/blob/master/lib/jekyll/readers/data_reader.rb#L36

Question: Is this an intended feature, or merely something no-one has considered as a use case yet? My use case is an open data portal, where we host various .csv files (of government budgets, etc.), with a corresponding .json file that is the dcat:Dataset for the .csv file. There are valid reasons to have similarly named files in varying formats, so this seems like it would be useful (although I suppose fixing this would mean some data reading behaves subtly differently).

Thanks, Jekyll peeps!

@ashmaroli
Copy link
Member

Is this an intended feature, or merely something no-one has considered as a use case yet?

Irrespective of the intention / design, this issue cannot be addressed without breaking existing workflows especially since the current behavior has remained the same from the time the feature was introduced.

Perhaps this may get considered for a v5.0.0 (which won't be happening in the near future).

ShaneCurcuru added a commit to ArlingtonMA/arlingtonma.info that referenced this issue Jul 12, 2020
See jekyll/jekyll#8300 for why same names won't work
@ShaneCurcuru
Copy link
Author

Understood (and expected), I'll workaround; but please do consider this a plea for updating the docs to make it clear what order the files will be read in so others aren't surprised.

@ashmaroli
Copy link
Member

ashmaroli commented Jul 12, 2020

consider this a plea for updating the docs

The docs already contain a fleeting reference to this behavior:

This data can be accessed via site.data.members (notice that the filename
determines the variable name).

That said, I'll update I've updated that line to reduce assumptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants