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

fixtures: update ROR affiliations data as of 2024-05-02 #281

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Samk13
Copy link
Member

@Samk13 Samk13 commented May 4, 2024

❤️ Thank you for your contribution!

Description

Here is the code used to convert the data for easier review:

import json
import yaml


def convert_json_to_yaml(json_filepath, yaml_filepath):
    with open(json_filepath, 'r', encoding='utf-8') as json_file, open(yaml_filepath, 'w', encoding='utf-8') as yaml_file:
        data = json.load(json_file)

        yaml_data = []
        for item in data:
            identifier_entry = {
                'identifier': item['id'].split('/')[-1],
                'scheme': 'ror'
            }

            # Prepare the title structure with translations if available
            title = {'en': item['name']}  # default to English title
            for label in item.get('labels', []):
                if label.get('iso639') and label.get('label'):
                    title[label['iso639']] = label['label']

            # Prepare the basic YAML entry structure
            yaml_entry = {
                'id': item['id'].split('/')[-1],
                'name': item['name'],
                'title': title,
                'identifiers': [identifier_entry]
            }

            # Check if acronyms is not empty and add if it's not
            if item['acronyms'] and item['acronyms'][0] != "":
                yaml_entry['acronym'] = item['acronyms'][0]

            yaml_data.append(yaml_entry)

        yaml.safe_dump(yaml_data, yaml_file, allow_unicode=False, default_flow_style=False)


json_input = "v1.46-2024-05-02-ror-data.json"
yaml_output = "affiliations_ror.yaml"

convert_json_to_yaml(json_input, yaml_output)

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Frontend

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

* Updated ROR data as of 2024-05-02
* Source: <https://github.com/ror-community/ror-data/blob/main/v1.46-2024-05-02-ror-data.zip>
* Converted "v1.46-2024-05-02-ror-data.json" with ` allow_unicode=False`
* Included additional title languages, where available
* Included acronyms only where they exist
@Samk13 Samk13 added the enhancement New feature or request label May 4, 2024
@Samk13 Samk13 changed the title fixtures: update ROR affiliations data fixtures: update ROR affiliations data as of 2024-05-02 May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: To review
Development

Successfully merging this pull request may close these issues.

None yet

1 participant