Batch Subjects

From UA Libraries Digital Services Planning and Documentation
Jump to: navigation, search

Sometimes it makes more sense to work with an exported tab-delimited spreadsheet, rather than interactively one entry at a time.

These initial scripts currently run on commandline.

The first two are located in S:\Digital Projects\Administrative\scripts\Metadata\subFix\ was written to test a tab-delimited spreadsheet without headers, but which has the following content in columns in this order:

  • Number of files
  • Original Subject Heading
  • Corrected Subject Heading
  • Original Authority
  • Corrected Authority
  • Notes

This script is only checking the Corrected Subject Heading and the Corrected Authority fields against what's in the subject database. If the values are NOT found, it will generate a tab-delimited spreadsheet of the form described below, so that the new subject headings can be easily added to the subject database.

Any errors encountered will be written to "errors.txt" in the same directory. expects a tab-delimited file called "toSubjectDbase.txt" with the following column headings:

  • DatabaseNum
  • SubjectHeading
  • TaggedValue
  • Authority
  • SecondaryAuthority
  • If the value in the DatabaseNum field is "ADD" then a new entry will be created in the database.
  • If the value in the SubjectHeading field is "DELETE" then an existing heading will be deleted (using the DatabaseNum to identify which to delete)
  • Otherwise, the script will update whatever is in the database corresponding to the given database number (in DatabaseNum) with whatever has been entered in this row. Nothing of the original entry will be retained except the database number.

If this script encounters errors, it will output them in a file named "toSubsDbaseErrors.txt" in the same directory. is located in S:\Metadata\Authorities\FromDatabase . This script will collect all the entries in the current subjects database table and print them to a tab-delimited text file with the following headers:

  • DatabaseNumber
  • SubjectHeading
  • TaggedValue
  • Authority
  • SecondaryAuthority

The file generated is called "Subjects.txt" and it is currently output in S:\Metadata\Authorities\.

Personal tools