Skip to content

Instantly share code, notes, and snippets.

@timtomch
Created November 17, 2021 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timtomch/b4fc0ad514c9689bf537c82686a0d2d3 to your computer and use it in GitHub Desktop.
Save timtomch/b4fc0ad514c9689bf537c82686a0d2d3 to your computer and use it in GitHub Desktop.
Count DPLA objects by rights status
def counter(stream):
reduce stream as $s ({}; .[$s|tostring] += 1);
counter(.[] | select(."_source".sourceResource.type) | select(."_source".sourceResource.type[] | test("^image|physical object")) | ."_source".rights)
@timtomch
Copy link
Author

timtomch commented Nov 17, 2021

Call as jq -s -f rightscounter.jq <inputfile(s)>
Works with multiple input files as well, count will be collated across files. Doesn't work well with too many large files, causes script to crash.

References:

@timtomch
Copy link
Author

Other tools considered:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment