Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions flopy/mf6/data/mfdataplist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1775,10 +1775,14 @@ def _write_file_entry(
return ""

# Write out pre-data comments (including headers) like MFList does
mode = "w"
if fd_data_file is not None and data_storage.pre_data_comments:
if not hasattr(fd_data_file, "write"):
fd_data_file = open(fd_data_file, "w")
fd_data_file.write(data_storage.pre_data_comments.get_file_entry())
if hasattr(fd_data_file, "write"):
fd_data_file.write(data_storage.pre_data_comments.get_file_entry())
else:
mode = "a"
with open(fd_data_file, "w") as f:
f.write(data_storage.pre_data_comments.get_file_entry())

# Loop through data pieces
data = self._remove_cellid_fields(data_storage.internal_data)
Expand Down Expand Up @@ -1828,6 +1832,7 @@ def _write_file_entry(
sep=" ",
header=False,
index=False,
mode=mode,
float_format=float_format,
lineterminator="\n",
)
Expand Down
Loading