original_docstring: Prepares JSON file for import to MongoDB
docstring: Prepares JSON file for import to MongoDB
docstring_tokens: Prepares JSON file for import to MongoDB
code: def prepare_manual_import(raw_data_file: str, source_url: str, last_date: str = None):
      """Prepares JSON file for import to MongoDB"""
      last_date = last_date or (datetime.now() - timedelta(days=2)).date().isoformat()
      if last_date:
          print(f"Will load cases before {last_date}")
      from tqdm import tqdm
      source_id = f"{Path(__file__).stem.lower()}-manual-import"
      case_json = Path('cases.json')
      if case_json.exists():
          print("Existing cases.json found, remove and rerun")
          return None
      with case_json.open('w') as f:
          for c in tqdm(parse_cases(raw_data_file, source_id, source_url, last_date, manual_import=True)):
              for non_null_field in ['symptoms', 'preexistingConditions']:
                  if c[non_null_field] is None:
                      del c[non_null_field]
              f.write(json.dumps(c) + "\n")
code_tokens: def prepare_manual_import ( raw_data_file : str , source_url : str , last_date : str = None ) : last_date = last_date or ( datetime . now ( ) - timedelta ( days = 2 ) ) . date ( ) . isoformat ( ) if last_date : print ( f"Will load cases before {last_date}" ) from tqdm import tqdm source_id = f"{Path(__file__).stem.lower()}-manual-import" case_json = Path ( 'cases.json' ) if case_json . exists ( ) : print ( "Existing cases.json found, remove and rerun" ) return None with case_json . open ( 'w' ) as f : for c in tqdm ( parse_cases ( raw_data_file , source_id , source_url , last_date , manual_import = True ) ) : for non_null_field in [ 'symptoms' , 'preexistingConditions' ] : if c [ non_null_field ] is None : del c [ non_null_field ] f . write ( json . dumps ( c ) + "\n" )
short_docstring: Prepares JSON file for import to MongoDB
short_docstring_tokens: Prepares JSON file for import to MongoDB
comment: """Prepares JSON file for import to MongoDB"""