Skip to content

Commit 89b2a36

Browse files
authored
Merge pull request #28 from AmericanPhilosophicalSociety/merge-fillable
Merge wb-fillable and wb-blank, fix formatting issues, etc.
2 parents bd8fc2c + 176ede7 commit 89b2a36

12 files changed

Lines changed: 392 additions & 513 deletions

README.md

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ cd C:/Users/username/Desktop/aspace-wb-scripts
8181

8282
## Prepare necessary files
8383

84-
### Prepare media files (required)
84+
### Prepare media files (highly recommended)
8585

8686
+ Copy your media files into ```files_to_upload```. Do NOT run the script directly on files in the Digital Library Staging Area.
8787
+ Your files should be named according to [CDS guidelines](https://americanphilosophicalsociety.github.io/APS_digitization/metadata/#file).
@@ -101,38 +101,39 @@ If the collection you're ingesting already has a finding aid, you can follow the
101101

102102
This code provides you with a set of command line utilities that can be used to perform various Workbench-related tasks. These are designed to be used in sequence.
103103

104-
Some of these commands take optional **flags**, which give the scripts additional information about how to process your data. Flags are parameters like ```--fields``` or ```--filefolder``` that you can include in your commands, usually followed by some other piece of information such as a file name or variable. For more information and examples, see the sections below.
104+
Some of these commands take optional **flags**, which give the scripts additional information about how to process your data. Flags are parameters like ```--fields``` or ```--files``` that you can include in your commands, usually followed by some other piece of information such as a file name or variable. For more information and examples, see the sections below.
105105

106-
### Create fillable spreadsheet (```wb-fillable``` or ```wb-blank```)
106+
### Create fillable spreadsheet (```wb-fillable```)
107107

108108
Creates a simplified version of a Workbench spreadsheet, with some data prepopulated. Data is pulled from media files, with the option to add additional data from an ArchivesSpace bulk update spreadsheet.
109109

110110
| Information | Acceptable input | Required? | Flag | Example
111111
| --- | --- | --- | --- | --- |
112-
| Workbench upload type | ```book``` (an object with multiple pages) or ```single``` (a graphic, audio, or video object) | Yes | | book |
112+
| Workbench upload type | ```book``` (an object with multiple pages) or ```single``` (a graphic, audio, video, or PDF object) | Yes | | book |
113113
| Fields to include | Name of a .csv file containing a list of fields to include. Omit the .csv extension. You can create your own custom list (see below) or use one of the preset options: ```example_minimum_book```, ```example_minimum_single```, ```cnairaudio```, ```cnairbook```, or ```cnairimage```. If no list of fields is specified, all valid Workbench fields will be included. | Recommended | ```--fields``` | example_minimum_book |
114114
| Bulk update spreadsheet | Name (with .xlsx extension) of an adapted ArchivesSpace bulk update spreadsheet file | Recommended | ```--AS``` | update.xlsx
115-
| Path to media folder | Location of the folder containing your media files. Only necessary if you haven't copied these files into ```/files_to_upload```. Use forward slashes and if any directory names contain spaces, surround them in quotes. | No | ```--filefolder``` | C:/Users/yshiroma/Desktop/"Files to Upload" |
115+
| Path to media folder | Location of the folder containing your media files. Only necessary if you haven't copied these files into ```/files_to_upload```. Use forward slashes and if any directory names contain spaces, surround the path in quotes. | No | ```--files``` | "C:/Users/yshiroma/Desktop/Files to Upload" |
116+
| Output blank sheet? | Use this flag if you want to create a blank Workbench sheet using only the specified fields and field descriptions. This flag does not take any input. | No | ```--blank``` | |
116117

117118
Example command with minimum required information:
118119

119120
```bash
120121
wb-fillable book
121122
```
122123

123-
Example command with all flags:
124+
Example command to use a custom set of fields, ArchivesSpace data, and file path:
124125

125126
```bash
126-
wb-fillable book --fields fields_file --AS archivesspace_file.xlsx --filefolder C:/Users/username/Desktop/"Folder Name"
127+
wb-fillable book --fields fields_file --AS archivesspace_file.xlsx --files "C:/Users/username/Desktop/Folder Name"
127128
```
128129

129-
**To create a blank spreadsheet with a particular set of fields, without drawing any information from media files** run the following command:
130+
Example command to create a blank spreadsheet from a particular set of fields, without drawing any information from media files or ArchivesSpace:
130131

131132
```bash
132-
wb-blank book --fields fields_file
133+
wb-fillable book --fields fields_file --blank
133134
```
134135

135-
Check in ```/metadata``` that your output has been created successfully. It should be named ```output_wb-fillable``` or ```output_wb-blank```, depending on which script you used (with 'output' replaced by the name of your ArchivesSpace bulk update sheet if you provided one).
136+
Check in ```/metadata``` that your output has been created successfully. It should be named ```output_wb-fillable``` (with 'output' replaced by the name of your ArchivesSpace bulk update sheet if you provided one).
136137

137138
### Manually fill spreadsheet
138139

@@ -143,7 +144,7 @@ Fill out the remaining fields according to standard Workbench guidelines, with a
143144
+ ```id```, ```parent_id```, ```field_weight```, ```field_display_hints```, and ```field_metadata_title``` are omitted in ```output_wb_fillable``` because they will be filled in automatically later by ```wb-to-wb```
144145
+ For any field marked "Fills down," you can fill in a value only once and it will be auto-filled to any blank cell below it in that column
145146
+ ```field_language``` can be entered as an ISO639 language name or code
146-
+ ```field_linked_agent``` is broken out into ```field_linked_agent_NAME```, ```field_linked_agent_ROLE```, and ```field_linked_agent_TYPE```, making it possible to enter these pieces of information separately. If there are multiple linked agents, entries should be pipe-separated.
147+
+ ```field_linked_agent``` is broken out into ```field_linked_agent_NAME```, ```field_linked_agent_RELATOR```, and ```field_linked_agent_TYPE```, making it possible to enter these pieces of information separately. If there are multiple linked agents, entries should be pipe-separated.
147148

148149
For example, consider the following ```field_linked_agent``` entry from a standard Workbench sheet:
149150

@@ -154,7 +155,7 @@ The examples below show how this same data would be entered into ```output_wb-fi
154155
| Field | Description | Example |
155156
| --- | --- | --- |
156157
| ```field_linked_agent_NAME``` | Name, in Library of Congress subject heading format | Nussbaum, Martha, 1947-\|American Philosophical Society |
157-
| ```field_linked_agent_ROLE``` | Relator code, from list of Default Relationship Types | cre\|pbl |
158+
| ```field_linked_agent_RELATOR``` | Relator code, from list of Default Relationship Types | cre\|pbl |
158159
| ```field_linked_agent_TYPE``` | Type of linked agent (```person```, ```corporate_body```, or ```family```), or an abbreviation (```p```, ```c```, or ```f```). If left blank, all entires are assumed to be persons. | person\|corporate_body |
159160

160161

@@ -256,13 +257,6 @@ Testing/sample data is currently lacking. This should include sample media for v
256257
- There is currently no way to validate field entry against Islandora controlled vocabularies themselves unless they are explicitly downloaded into /vocabularies/ and code added to validate them (in ```wb-validate``` calling a function in utils/validate.py)
257258
- Agents from ArchivesSpace must currently come from a custom report where the maximum (50k rows, we need something close to 80k) is overridden using the browser inspect tool. An API call could be an improvement. There is currently [a ticket](https://archivesspace.atlassian.net/browse/ANW-2376) with ArchivesSpace to include agents (and all subjects and all other fields) in the spreadsheet.
258259

259-
# To do
260-
261-
- Replace language vocabulary with one that uses ISO639-2B where different to ISO639-3 (~20 cases). Probably necessary to replace the json extraction with something that uses the ISO639 library. Alternatively, have an ISO639-2B vocabulary of these differences and reference that, as they are unlikely to change. Temporary fix was to just edit the iso639.csv file to use 2B for a few languages.
262-
- To avoid duplication, the functionality of ```wb-blank``` (which is ```wb-fillable``` but bypassing any file metadata) could be incorporated into ```wb-fillable``` using a flag, e.g. --blank. This would require putting the file checking and metadata extraction into dedicated functions.
263-
- After upgrade to ArchivesSpace v4, adapt Bulk Update Spreadsheet instructions and check for any discrepency between old and new sheets.
264-
- reorder output of ```wb-create-dos``` so all AS-entry fields are to the right
265-
266260
# Contributing
267261

268262
This library is under active development and welcomes contributions. Please work from the existing issues before submitting a pull request.

aspace_wb/cli/create_blank_fillable.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

aspace_wb/scripts/create_aspace_dos.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
from aspace_wb.utils import default_specs as c
99
from aspace_wb.utils import convert_data
1010
from aspace_wb.utils import use_CSVs
11+
import aspace_wb.utils.extract_file as extract_file
1112

1213
'''
1314
Parse command line arguments
1415
required, positional: nodes file (csv)
1516
'''
16-
print('Checking command line arguments - expected: [nodes csv file] ...')
1717

1818
cl_parser = argparse.ArgumentParser()
1919
cl_parser.add_argument('nodes_file', type=str, help="Name of your Workbench output CSV (with .csv extension)")
@@ -22,9 +22,7 @@
2222

2323
# check existence of file
2424
if not os.path.exists(os.path.join(c.METADATA_DIR, NODES_FILE)):
25-
raise OSError(f"Workbench output CSV {str(NODES_FILE)} not found in folder {str(c.METADATA_DIR)}. Check file name and location and try again.")
26-
27-
print("... command line arguments okay ...")
25+
raise FileNotFoundError(f"Workbench output CSV {str(NODES_FILE)} not found in folder {str(c.METADATA_DIR)}. Check file name and location and try again.")
2826

2927
'''
3028
Load the nodes
@@ -83,19 +81,9 @@
8381
output_pandas_DF = pandas.DataFrame(data=output_dict)
8482

8583
# create output filename
86-
OUTPUT_FILENAME = f"{os.path.splitext(NODES_FILE)[0]}_wb-create-dos"
87-
OUTPUT_EXTENSION = ".xlsx"
88-
89-
# if file already exists, append a counter to prevent overwriting
90-
while os.path.exists(os.path.join(c.METADATA_DIR, f"{OUTPUT_FILENAME}{OUTPUT_EXTENSION}")):
91-
filename_split = OUTPUT_FILENAME.split("_")
92-
if filename_split[-1].isdigit():
93-
counter = int(filename_split[-1]) + 1
94-
OUTPUT_FILENAME = f"{'_'.join(filename_split[:-1])}_{counter}"
95-
else:
96-
OUTPUT_FILENAME += "_2"
97-
98-
filename = f"{OUTPUT_FILENAME}{OUTPUT_EXTENSION}"
99-
output_pandas_DF.to_excel(os.path.join(c.METADATA_DIR, filename), index=False)
100-
101-
print(f'Done. Created file: {os.path.join(c.METADATA_DIR, filename)}')
84+
FILE_PREFIX = os.path.splitext(NODES_FILE)[0]
85+
FILE_NAME = extract_file.construct_output_filename(FILE_PREFIX, ".xlsx", "wb-create-dos")
86+
87+
output_pandas_DF.to_excel(os.path.join(c.METADATA_DIR, FILE_NAME), index=False)
88+
89+
print(f'Done. Created file: {os.path.join(c.METADATA_DIR, FILE_NAME)}')

aspace_wb/scripts/create_blank_fillable.py

Lines changed: 0 additions & 154 deletions
This file was deleted.

0 commit comments

Comments
 (0)