diff --git a/flopy/mf6/data/mfdatalist.py b/flopy/mf6/data/mfdatalist.py index 761dd10888..eae0a66b7b 100644 --- a/flopy/mf6/data/mfdatalist.py +++ b/flopy/mf6/data/mfdatalist.py @@ -1045,26 +1045,38 @@ def _get_file_entry_record( ks_structs = [keystr_struct] ks_struct_index = 0 max_index = len(ks_structs) - 1 - for data_index in range( - index, data_complete_len - ): + data_index = index + while data_index != data_complete_len: if data_line[data_index] is not None: try: k_data_item = ks_structs[ ks_struct_index ] - text_line.append( - to_string( - data_line[data_index], - k_data_item.type, - self._simulation_data, - self._data_dimensions, - k_data_item.is_cellid, - k_data_item.possible_cellid, - k_data_item, - self._simulation_data.verify_data, + if ( + k_data_item.type + == DatumType.keyword + ): + if ( + data_line[data_index] + is not None + ): + text_line.append( + k_data_item.display_name + ) + else: + text_line.append( + to_string( + data_line[data_index], + k_data_item.type, + self._simulation_data, + self._data_dimensions, + k_data_item.is_cellid, + k_data_item.possible_cellid, + k_data_item, + self._simulation_data.verify_data, + ) ) - ) + data_index += 1 except Exception as ex: message = ( "An error occurred " @@ -1105,6 +1117,8 @@ def _get_file_entry_record( # increment until last record # entry then repeat last entry ks_struct_index += 1 + else: + data_index += 1 index = data_index elif data_val is not None and ( not isinstance(data_val, float) diff --git a/flopy/mf6/data/mffileaccess.py b/flopy/mf6/data/mffileaccess.py index e3fa5f9da0..e78ecbf0fd 100644 --- a/flopy/mf6/data/mffileaccess.py +++ b/flopy/mf6/data/mffileaccess.py @@ -1733,7 +1733,9 @@ def load_list_line( data_item_ks, MFDataStructure ): dis = data_item_ks.data_item_structures - for ks_data_item in dis: + for idx, ks_data_item in enumerate( + dis + ): if ( ks_data_item.type != DatumType.keyword @@ -1758,6 +1760,12 @@ def load_list_line( data_line, zero_based=zero_based, ) + elif ( + idx > 0 + and ks_data_item.type + == DatumType.keyword + ): + data_index += 1 while data_index < arr_line_len: try: # append remaining data @@ -1777,7 +1785,7 @@ def load_list_line( repeat_count, current_key, data_line, - zero_base=zero_based, + zero_based=zero_based, ) except MFDataException: break