Skip to content

Issue #1858 Reading mete_grid.inp crashes on empty lines#1867

Merged
rleander73 merged 3 commits into
masterfrom
Issue_#1858_MetaSWAP_empty_line
Jun 25, 2026
Merged

Issue #1858 Reading mete_grid.inp crashes on empty lines#1867
rleander73 merged 3 commits into
masterfrom
Issue_#1858_MetaSWAP_empty_line

Conversation

@rleander73

Copy link
Copy Markdown
Contributor

Included reading of the mete_grid.inp in the existing write test:
test_meteo_grid_write_read

Fixes #
Crash on empty line in mete_grid.inp file

Description

Checklist

  • [*] Links to correct issue
  • [-] Update changelog, if changes affect users
  • [*] PR title starts with Issue #nr, e.g. Issue #737
  • [*] Unit tests were added
  • [-] If feature added: Added/extended example
  • [-] If feature added: Added feature to API documentation
  • [-] If pixi.lock was changed: Ran pixi run generate-sbom and committed changes

…read of the produced file with inserted empty lines
@rleander73 rleander73 self-assigned this Jun 17, 2026
@rleander73 rleander73 marked this pull request as ready for review June 17, 2026 11:51

@JoerivanEngelen JoerivanEngelen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I have two small suggestions!

Comment thread imod/msw/meteo_mapping.py Outdated
Comment on lines +54 to +55
potential_paths.append(cols[column_nr].replace('"', ""))
if _is_parsable_and_existing_path(potential_paths[-1], mete_grid_path):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this improves readability:

Suggested change
potential_paths.append(cols[column_nr].replace('"', ""))
if _is_parsable_and_existing_path(potential_paths[-1], mete_grid_path):
potential_path = cols[column_nr].replace('"', "")
potential_paths.append(potential_paths)
if _is_parsable_and_existing_path(potential_path, mete_grid_path):

Comment thread imod/msw/meteo_mapping.py Outdated
potential_paths = []
for line in lines:
cols = line.strip().split(",")
if len(cols) > column_nr:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment why this check is necessary? Perhaps only do this when len(cols) == 0? Else throw error?

@rleander73 rleander73 added this pull request to the merge queue Jun 25, 2026
Merged via the queue into master with commit 4b10de5 Jun 25, 2026
8 checks passed
@rleander73 rleander73 deleted the Issue_#1858_MetaSWAP_empty_line branch June 25, 2026 09:23
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants