|
| 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