Changeset 38488 for other-projects


Ignore:
Timestamp:
2023-12-12T15:54:19+13:00 (5 months ago)
Author:
jc550
Message:

add part of convertFile function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/metadata-encoding/py/xRefToMongo.py

    r38486 r38488  
    11#program to convert xref metadata files into compatible files for mongo database
    22
    3 import pymongo, gzip, argparse
     3import pymongo, gzip, argparse, json
    44
     5numFile = 0
     6
     7#convert std xref metadata file
    58def 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
    722
    823def convertFileVerbose(path):
     
    3348        processDir(parsedArgs.verbose, parsedArgs.filePath, parsedArgs.count)
    3449
     50
    3551    #print(parsedArgs.count)
    3652
Note: See TracChangeset for help on using the changeset viewer.