Created
July 31, 2025 22:38
-
-
Save pgwillia/3c2bd97425b4c1c3d213c50ee8ba93ab to your computer and use it in GitHub Desktop.
Use DataCite API to complete Old URL column for ISTL journal migration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'net/http' | |
| require 'json' | |
| require 'csv' | |
| CSV.open('istl_url.csv', 'wb') do |csv| | |
| csv << ['doi', 'url'] | |
| File.open("istl_doi.txt") do |f| | |
| f.each_line(chomp: true) do |doi| | |
| source = URI.parse("https://api.datacite.org/dois/#{doi}") | |
| resp = Net::HTTP.get_response(source) | |
| data = resp.body | |
| result = JSON.parse(data).to_h | |
| csv << [result['data']['id'], result['data']['attributes']['url']] # needs error handling, I'm manually editing istl_doi.txt to keep this going | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment