Python 创建将文件加载到mongodb的定义

Python 创建将文件加载到mongodb的定义,python,mongodb,Python,Mongodb,如果文件尚未加载,如何将其加载到MongoDB数据库中?但是,如果文件为空或已加载,则不应加载该文件 def json_to_mongo(file_name, collection_name): if ??? : print("The collection already exists and is not empty.") return

如果文件尚未加载,如何将其加载到MongoDB数据库中?但是,如果文件为空或已加载,则不应加载该文件

def json_to_mongo(file_name, collection_name):
    if ???  :
        print("The collection already exists and is not empty.")
        return