def run(): path_config.create_dirs(path_config.get_container_dir_path()) popong_data_dump = fetch_popong_data_dump() assembly_members_data = append_additional_idxs(popong_data_dump) dump_file_path = path_config.get_single_file_path('assembly_members.json') with open(dump_file_path, 'w', encoding='utf-8') as out_file: json.dump(assembly_members_data, out_file, ensure_ascii=True) print('complete')
import db_config import json import os import path_config from datetime import datetime from pymongo import MongoClient import logging logging.basicConfig( format='[%(asctime)s] %(levelname)s : %(message)s', level=logging.INFO) CONTAINER_DIR = path_config.get_container_dir_path() def dump_data_dir(db, dir_name): dir_path = os.path.join(CONTAINER_DIR, dir_name) logging.info('insert_files_to_mongo: begin: %s' % dir_path) if not os.path.exists(dir_path): logging.warning('insert_files_to_mongo: cancelled: no dir') return files = os.listdir(dir_path) coll = db[dir_name] skip_count = 0 for filename in files: file_lower = filename.lower()