Skip to content

Commit 9d32853

Browse files
ougxwpbonelli
andauthored
fixBug: not reading comma separated data correctly (#1634)
* 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]>
1 parent 176af06 commit 9d32853

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,5 @@ autotest/.noseids
9191
.docs/_notebooks
9292

9393
*.bak
94+
95+
**.env

autotest/test_datautil.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
from flopy.utils.datautil import PyListUtil
2+
3+
14
def test_split_data_line():
2-
# TODO: try to reproduce this: https://github.com/modflowpy/flopy/runs/7581629193?check_suite_focus=true#step:11:1753
3-
pass
5+
# fixes: https://github.com/modflowpy/flopy/runs/7581629193?check_suite_focus=true#step:11:1753
6+
7+
line = "13,14,15, 16, 17,"
8+
spl = PyListUtil.split_data_line(line)
9+
exp = ["13", "14", "15", "16", "17"]
10+
assert len(spl) == len(exp)
11+
# whitespace is not removed, todo: can it be?
12+
# or is it needed to support Modflow input file format?
13+
assert all(any([e in s for s in spl]) for e in exp)

flopy/utils/datautil.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ def split_data_line(line, external_file=False, delimiter_conf_length=15):
329329
if alt_split_len > max_split_size:
330330
max_split_size = len(alt_split)
331331
max_split_type = delimiter
332+
max_split_list = alt_split
332333
elif alt_split_len == max_split_size:
333334
if (
334335
max_split_type not in PyListUtil.delimiter_list

0 commit comments

Comments
 (0)