@@ -770,18 +770,6 @@ def _combine_contents(self, contents: list, csv_encoding, use_chunking=False):
770
770
771
771
raise ValueError ('content is empty' )
772
772
773
- def __check_csv_info_value (self , csv_info : CsvFileType , col : str ):
774
- """Look for a column in a CSV file
775
-
776
- :param csv_info: The CSV file
777
- :param col: The column name
778
- :return: Either column information or False for not found
779
- """
780
- csv_info_dict = asdict (csv_info )
781
- if col in csv_info_dict :
782
- return csv_info_dict [col ]
783
- return False
784
-
785
773
def check_duplicates (self , content_keys_df , keys , error_file = None ):
786
774
"""Check a content frame for duplicate keys
787
775
@@ -905,14 +893,31 @@ def extract_csv_content(self, csv_info: CsvFileType,
905
893
:param core_ext_type: Whether this is a core or extension content frame
906
894
:param build_coreid_for_ext: indicator to build id and core id to support dwca with extension
907
895
"""
896
+ def __get_default_core_key (core_sv_info : CsvFileType ):
897
+ """Look for a column in a CSV file
898
+
899
+ :param csv_info: The CSV file
900
+ :param col: The column name
901
+ :return: Either column information or False for not found
902
+ """
903
+ if not core_sv_info .keys or len (core_sv_info .keys ) == 0 :
904
+ if core_sv_info .type == MetaElementTypes .EVENT :
905
+ return ["eventID" ]
906
+ elif core_sv_info .type == MetaElementTypes .OCCURRENCE :
907
+ return ["occurrenceID" ]
908
+ else :
909
+ raise ValueError ("Keys need to be set for core content" )
910
+ elif len (core_sv_info .keys ) > 0 :
911
+ return core_sv_info .keys
912
+
908
913
if isinstance (csv_info .files , pd .DataFrame ):
909
- csv_content = csv_info .files . copy ( deep = True )
914
+ csv_content = csv_info .files
910
915
else :
911
916
csv_content = self ._combine_contents (csv_info .files , csv_info .csv_encoding )
912
917
913
918
# Use default occurrenceID if not provided
914
919
if core_ext_type == CoreOrExtType .CORE :
915
- keys = csv_info . keys if self . __check_csv_info_value (csv_info , 'keys' ) else [ 'occurrenceID' ]
920
+ keys = __get_default_core_key (csv_info )
916
921
else :
917
922
keys = self .core_content .keys
918
923
core_id_field : str = ""
0 commit comments