Crossref journal names

from alexandria3k.data_sources import journal_names
class data_sources.journal_names.JournalNames(data_source, sample=<function JournalNames.<lambda>>, attach_databases=None)

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

Parameters
  • data_source (str) – The location (file path or URL) where the journal data are located.

  • sample (callable, optional) – A callable to row sampling, defaults to lambda n: True. The population or query method will call this argument for each record with the record’s data as its argument. When the callable returns True the 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 journal_names(
  id,
  title,
  crossref_id,
  publisher,
  issn_print,
  issn_eprint,
  issns_additional,
  doi,
  volume_info
);

CREATE TABLE journals_issns(
  journal_id,
  issn,
  issn_type
);