Skip to content

Commit

Permalink
fixBug: not reading comma separated data correctly (#1634)
Browse files Browse the repository at this point in the history
* fixBug: not reading comma separated data correctly

To test:
```python
from flopy.utils.datautil import PyListUtil
line = '13,14'
```
PyListUtil.split_data_line(line)

* test(PyListUtil): add minimal test for split_data_line()

Co-authored-by: w-bonelli <[email protected]>
  • Loading branch information
ougx and wpbonelli authored Nov 23, 2022
1 parent 176af06 commit 9d32853
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,5 @@ autotest/.noseids
.docs/_notebooks

*.bak

**.env
14 changes: 12 additions & 2 deletions autotest/test_datautil.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
from flopy.utils.datautil import PyListUtil


def test_split_data_line():
# TODO: try to reproduce this: https://github.com/modflowpy/flopy/runs/7581629193?check_suite_focus=true#step:11:1753
pass
# fixes: https://github.com/modflowpy/flopy/runs/7581629193?check_suite_focus=true#step:11:1753

line = "13,14,15, 16, 17,"
spl = PyListUtil.split_data_line(line)
exp = ["13", "14", "15", "16", "17"]
assert len(spl) == len(exp)
# whitespace is not removed, todo: can it be?
# or is it needed to support Modflow input file format?
assert all(any([e in s for s in spl]) for e in exp)
1 change: 1 addition & 0 deletions flopy/utils/datautil.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ def split_data_line(line, external_file=False, delimiter_conf_length=15):
if alt_split_len > max_split_size:
max_split_size = len(alt_split)
max_split_type = delimiter
max_split_list = alt_split
elif alt_split_len == max_split_size:
if (
max_split_type not in PyListUtil.delimiter_list
Expand Down

0 comments on commit 9d32853

Please sign in to comment.