Changeset 38488 for other-projects
- Timestamp:
- 2023-12-12T15:54:19+13:00 (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/metadata-encoding/py/xRefToMongo.py
r38486 r38488 1 1 #program to convert xref metadata files into compatible files for mongo database 2 2 3 import pymongo, gzip, argparse 3 import pymongo, gzip, argparse, json 4 4 5 numFile = 0 6 7 #convert std xref metadata file 5 8 def convertFile(path): 6 pass 9 jsonItems = "" 10 with gzip.open(path, "r", encoding="utf-8") as gzippedFile: 11 jsonDictionary = json.load(gzippedFile) 12 for item in jsonDictionary["items"]: 13 dictToDump = {"_id":numFile,} 14 if "DOI" in item.keys(): 15 dictToDump.update({"DOI":item["DOI"]}) 16 if "title" in item.keys(): 17 dictToDump.update({"title":item["title"][0]}) 18 if "subtitle" in item.keys(): 19 dictToDump.update({"subtitle":item["subtitle"][0]}) 20 21 7 22 8 23 def convertFileVerbose(path): … … 33 48 processDir(parsedArgs.verbose, parsedArgs.filePath, parsedArgs.count) 34 49 50 35 51 #print(parsedArgs.count) 36 52
Note:
See TracChangeset
for help on using the changeset viewer.