def csv_dataframe_to_checklist( checklist: pd.DataFrame, taxonomy: Taxonomy, local_translation_context: LocalTranslationContext, observer_name: str, xdates: List[str]) -> Optional[pd.DataFrame]: # Use column names from eBird and let them be fixed by transform_checklist_details # These all have to be present for transform_checklist_details if set(checklist.columns) & {'CommonName', 'Total'} == set(): return None cleaned_common_names = clean_common_names(checklist.CommonName, taxonomy, local_translation_context) checklist.CommonName = cleaned_common_names # This will get switched back by transform_checklist_details checklist.rename(columns={'Total': 'howManyStr'}, inplace=True) xdtypes = {'CommonName': str, 'howManyStr': int} checklist = checklist.astype(dtype=xdtypes) checklist['speciesCode'] = [ taxonomy.find_species6_ebird(cn) for cn in checklist.CommonName ] checklist['locId'] = 'L5551212' checklist['subId'] = 'S5551212' checklist['groupId'] = '' checklist['durationHrs'] = 0.5 checklist['effortDistanceKm'] = 0.1 checklist['effortDistanceEnteredUnit'] = 'mi' # 'obsDt' needs dates in this form '26 Dec 2020' obsdt = normalize_date_for_visits(xdates[0]) checklist['obsDt'] = f'{obsdt} 12:01' checklist['userDisplayName'] = observer_name checklist['numObservers'] = 1 checklist['comments'] = 'Generated' # Clean up checklist = transform_checklist_details(checklist, taxonomy) return checklist