Skip to content

Commit c47fd8b

Browse files
committed
Cleanup/removing duplicate metadata
1 parent 146c613 commit c47fd8b

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

caltechdata_write/customize_schema.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def customize_schema(json_record):
3636
for t in titles:
3737
if 'titleType' not in t:
3838
json_record['title']=t['title']
39+
del json_record['titles']
3940

4041
#Language - only translating english
4142
if "language" in json_record:
@@ -69,6 +70,7 @@ def customize_schema(json_record):
6970
new['authorIdentifiers'] = idn
7071
newa.append(new)
7172
json_record['authors']=newa
73+
del json_record['creators']
7274

7375
#strip creator URI
7476
if "contributors" in json_record:
@@ -106,7 +108,7 @@ def customize_schema(json_record):
106108
json_record['relevantDates']=json_record.pop('dates')
107109

108110
if "publicationYear" in json_record:
109-
json_record["publicationDate"]=str(json_record["publicationYear"])
111+
json_record["publicationDate"]=str(json_record.pop("publicationYear"))
110112

111113
#license
112114
if 'rightsList' in json_record:
@@ -119,19 +121,19 @@ def customize_schema(json_record):
119121
#Only transfers first license
120122

121123
#Funding
122-
if 'fundingReferences' in json_record:
123-
funding = json_record['fundingReferences']
124-
newf = []
125-
for f in funding:
126-
frec = {}
127-
if 'funderName' in f:
128-
frec['fundingName'] = f['funderName']
129-
#f['fundingName']=f.pop('funderName')
130-
if 'awardNumber' in f:
131-
frec['fundingAwardNumber']=f['awardNumber']['awardNumber']
132-
newf.append(frec)
133-
json_record['fundings']=newf
134-
#Some fields not preserved
124+
#if 'fundingReferences' in json_record:
125+
# funding = json_record['fundingReferences']
126+
# newf = []
127+
# for f in funding:
128+
# frec = {}
129+
# if 'funderName' in f:
130+
# frec['fundingName'] = f['funderName']
131+
# #f['fundingName']=f.pop('funderName')
132+
# if 'awardNumber' in f:
133+
# frec['fundingAwardNumber']=f['awardNumber']['awardNumber']
134+
# newf.append(frec)
135+
# json_record['fundings']=newf
136+
# #Some fields not preserved
135137

136138
#Geo
137139
if 'geoLocations' in json_record:
@@ -149,7 +151,7 @@ def customize_schema(json_record):
149151
#Publisher
150152
if "publisher" in json_record:
151153
publisher = {}
152-
publisher['publisherName'] = json_record['publisher']
154+
publisher['publisherName'] = json_record.pop('publisher')
153155
json_record['publishers'] = publisher
154156

155157
#print(json.dumps(json_record))

0 commit comments

Comments
 (0)