Open Researcher and Contributor ID (ORCID) data

from alexandria3k.data_sources import orcid
class data_sources.orcid.Orcid(orcid_file, sample=<function Orcid.<lambda>>, attach_databases=None)

Create an object containing ORCID meta-data that supports queries over its (virtual) table and the population of an SQLite database with its data.

Parameters
  • orcid_file (str) – The file path to the compressed tar file containing ORCID data.

  • sample (callable, optional) – A callable to control container sampling, defaults to lambda n: True. The population or query method will call this argument for each ORCID person record with each ORCID as its argument. When the callable returns True the container record will get processed, when it returns False the record will get skipped.

  • attach_databases (list, optional) – A list of colon-joined tuples specifying a database name and its path, defaults to None. The specified databases are attached and made available to the query and the population condition through the specified database name.

populate(database_path, columns=None, condition=None)

Populate the specified SQLite database using the data specified in the object constructor’s call. The database is created if it does not exist. If it exists, the tables to be populated are dropped (if they exist) and recreated anew as specified.

Parameters
  • database_path (str) – The path specifying the SQLite database to populate.

  • columns (list, optional) – A list of strings specifying the columns to populate, defaults to None. The strings are of the form table_name.column_name or table_name.*.

  • condition (str, optional) – SQL expression specifying the rows to include in the database’s population, defaults to None. The expression can contain references to the table’s columns, to tables in attached databases prefixed by their name, and tables in the database being populated prefixed by populated. Implicitly, if a main table is populated, its details tables will only get populated with the records associated with the corresponding main table’s record.

query(query, partition=False)

Run the specified query on the virtual database using the data specified in the object constructor’s call.

Parameters
  • query (str) – An SQL SELECT query specifying the required data.

  • partition (bool, optional) – When true the query will run separately in each container, defaults to False. Queries involving table joins will run substantially faster if access to each table’s records is restricted with an expression table_name.container_id = CONTAINER_ID, and the partition argument is set to true. In such a case the query is repeatedly run over each database partition (compressed JSON file) with CONTAINER_ID iterating sequentially to cover all partitions. The query’s result is the concatenation of the individual partition results. Running queries with joins without partitioning will often result in quadratic (or worse) algorithmic complexity.

Returns

An iterable over the query’s results.

Return type

iterable

Generated schema

CREATE TABLE persons(
  id INTEGER PRIMARY KEY,
  container_id,
  orcid,
  given_names,
  family_name,
  biography
);

CREATE TABLE person_researcher_urls(
  id,
  container_id,
  person_id,
  name,
  url
);

CREATE TABLE person_countries(
  id,
  container_id,
  person_id,
  country
);

CREATE TABLE person_keywords(
  id,
  container_id,
  person_id,
  keyword
);

CREATE TABLE person_external_identifiers(
  id,
  container_id,
  person_id,
  type,
  value,
  url
);

CREATE TABLE person_distinctions(
  id,
  container_id,
  person_id,
  organization_name,
  organization_city,
  organization_region,
  organization_country,
  organization_identifier,
  department_name,
  role_title,
  start_year,
  start_month,
  start_day,
  end_year,
  end_month,
  end_day
);

CREATE TABLE person_educations(
  id,
  container_id,
  person_id,
  organization_name,
  organization_city,
  organization_region,
  organization_country,
  organization_identifier,
  department_name,
  role_title,
  start_year,
  start_month,
  start_day,
  end_year,
  end_month,
  end_day
);

CREATE TABLE person_employments(
  id,
  container_id,
  person_id,
  organization_name,
  organization_city,
  organization_region,
  organization_country,
  organization_identifier,
  department_name,
  role_title,
  start_year,
  start_month,
  start_day,
  end_year,
  end_month,
  end_day
);

CREATE TABLE person_invited_positions(
  id,
  container_id,
  person_id,
  organization_name,
  organization_city,
  organization_region,
  organization_country,
  organization_identifier,
  department_name,
  role_title,
  start_year,
  start_month,
  start_day,
  end_year,
  end_month,
  end_day
);

CREATE TABLE person_memberships(
  id,
  container_id,
  person_id,
  organization_name,
  organization_city,
  organization_region,
  organization_country,
  organization_identifier,
  department_name,
  role_title,
  start_year,
  start_month,
  start_day,
  end_year,
  end_month,
  end_day
);

CREATE TABLE person_qualifications(
  id,
  container_id,
  person_id,
  organization_name,
  organization_city,
  organization_region,
  organization_country,
  organization_identifier,
  department_name,
  role_title,
  start_year,
  start_month,
  start_day,
  end_year,
  end_month,
  end_day
);

CREATE TABLE person_services(
  id,
  container_id,
  person_id,
  organization_name,
  organization_city,
  organization_region,
  organization_country,
  organization_identifier,
  department_name,
  role_title,
  start_year,
  start_month,
  start_day,
  end_year,
  end_month,
  end_day
);

CREATE TABLE person_fundings(
  id,
  container_id,
  person_id,
  title,
  type,
  short_description,
  amount,
  url,
  start_year,
  start_month,
  start_day,
  end_year,
  end_month,
  end_day,
  organization_name,
  organization_city,
  organization_region,
  organization_country,
  organization_identifier
);

CREATE TABLE person_peer_reviews(
  id,
  container_id,
  person_id,
  reviewer_role,
  review_type,
  subject_type,
  subject_name,
  subject_url,
  group_id,
  completion_year,
  completion_month,
  completion_day,
  organization_name,
  organization_city,
  organization_region,
  organization_country
);

CREATE TABLE person_research_resources(
  id,
  container_id,
  person_id,
  title,
  start_year,
  start_month,
  start_day,
  end_year,
  end_month,
  end_day
);

CREATE TABLE person_works(
  id,
  container_id,
  person_id,
  doi
);