Skip to content

Instantly share code, notes, and snippets.

@pgwillia
Created March 13, 2025 21:09
Show Gist options
  • Save pgwillia/e7bbfaea5e683ee36ac7dda6399fc900 to your computer and use it in GitHub Desktop.
Save pgwillia/e7bbfaea5e683ee36ac7dda6399fc900 to your computer and use it in GitHub Desktop.
Creating a list of publishing doi's from json export files
require 'csv'
require 'json'
CSV.open('publishing_datacite_dois.csv', 'wb') do |csv|
csv << ['doi', 'title', 'url']
["10.18733.json", "10.20360.json", "10.21225.json", "10.21971.json", "10.18740.json", "10.20361.json", "10.21432.json", "10.21991.json", "10.25336.json"].each do |filename|
file = File.open filename
data = JSON.load file
data["data"].each do |doi|
csv << [doi["attributes"]["doi"], doi["attributes"]["titles"][0]["title"], doi["attributes"]["url"]]
end
file.close
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment