Skip to content

Commit 0f19e7d

Browse files
committed
updates
1 parent 8f5f693 commit 0f19e7d

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ Based on user input, removes all key-value pairs with the specified key and valu
7373
#### [editBitstreamsNames.py](editBitstreamsNames.py)
7474
Based on a specified CSV file of DSpace item handles and replacement file names, replaces the name of bitstreams attached to the specified items.
7575

76+
#### [generateCollectionLevelAbstract.py](generateCollectionLevelAbstract.py)
77+
Based on user input, creates an HTML collection-level abstract that contains hyperlinks to all of the items in each series, as found in the metadata CSV. This assumes that the series title is recorded in 'dc.relation.ispartof' or a similar property in the DSpace item records.
78+
7679
#### [overwriteExistingMetadata.py](overwriteExistingMetadata.py)
7780
Based on a specified CSV file of DSpace item handles and file identifiers, replaces the metadata of the items with specified handles with the set of metadata elements associated with the corresponding file identifier in a JSON file of metadata entries named 'metadataOverwrite.json.'
7881

fileListMetadataReconcile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
parser = argparse.ArgumentParser()
88
parser.add_argument('-d', '--directory', help='the directory of the files. optional - if not provided, the script will ask for input')
9-
parser.add_argument('-f', '--fileNameCSV', help='the metadata CSV. optional - if not provided, the script will ask for input')
9+
parser.add_argument('-f', '--fileNameCSV', help='the metadata CSV file. optional - if not provided, the script will ask for input')
1010
parser.add_argument('-e', '--fileExtension', help='the file extension. optional - if not provided, the script will ask for input')
1111
args = parser.parse_args()
1212

@@ -17,7 +17,7 @@
1717
if args.fileNameCSV:
1818
fileNameCSV = args.fileNameCSV
1919
else:
20-
fileNameCSV = raw_input('Enter metadata CSV: ')
20+
fileNameCSV = raw_input('Enter metadata CSV file: ')
2121
if args.fileExtension:
2222
fileExtension = args.fileExtension
2323
else:

generateCollectionLevelAbstract.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import csv
2+
import argparse
3+
4+
parser = argparse.ArgumentParser()
5+
parser.add_argument('-f', '--fileNameCSV', help='the metadata CSV file. optional - if not provided, the script will ask for input')
6+
parser.add_argument('-b', '--baseURL', help='the base URL to use for the series links. optional - if not provided, the script will ask for input')
7+
parser.add_argument('-i', '--handle', help='handle of the collection. optional - if not provided, the script will ask for input')
8+
args = parser.parse_args()
9+
10+
if args.fileNameCSV:
11+
fileNameCSV =args.fileNameCSV
12+
else:
13+
fileNameCSV = raw_input('Enter the metadata CSV file (including \'.csv\'): ')
14+
if args.baseURL:
15+
baseURL =args.baseURL
16+
else:
17+
baseURL = raw_input('Enter the base URL to use for the series links: ')
18+
if args.handle:
19+
handle = args.handle
20+
else:
21+
handle = raw_input('Enter collection handle: ')
22+
23+
handle = handle.replace('/', '%2F')
24+
25+
#Enter abstract text here
26+
abstractText = 'Educational slides played an important role in the history of public health campaign in P.R. China. From the beginning of the 1950s, Chinese government\'s health policy put an emphasis on public hygiene and preventive treatment. Along with radio, posters, and movies, slides became a favored propaganda tool for educating the public. Slides were inexpensive to produce and disseminate. They were widely used in school teaching and various public health activities/campaigns in both rural and urban China. These health slides aimed at disseminating scientific and medical concepts and behaviors among a population with very different understanding of what constituted illness and well-being.''
27+
28+
seriesTitles = []
29+
30+
with open(fileNameCSV) as csvfile:
31+
reader = csv.DictReader(csvfile)
32+
for row in reader:
33+
seriesTitle = row['Series title']
34+
if seriesTitle not in seriesTitles:
35+
seriesTitles.append(seriesTitle)
36+
37+
seriesLinks = ''
38+
39+
for seriesTitle in seriesTitles:
40+
editedSeriesTitle = seriesTitle.replace(' ','+')
41+
seriesLink = '<li><a href="'+baseURL+'discover?scope='+handle+'&query=%22'+editedSeriesTitle+'%22&sort_by=dc.title_sort&order=asc&submit=">'+seriesTitle+'</a></li>'
42+
seriesLinks += seriesLink
43+
44+
abstractText = '<p>'+abstractText+'</p>'
45+
seriesLinks = '<ul>'+seriesLinks+'</ul>'
46+
47+
f = open('collectionLevelAbstract.txt', 'wb')
48+
f.write(abstractText + seriesLinks)

0 commit comments

Comments
 (0)