From fc261e5ea9af7fb27fa7c6318dd2f44759f38baa Mon Sep 17 00:00:00 2001 From: Terrence Tricco Date: Thu, 18 Jan 2024 16:51:25 -0330 Subject: [PATCH] keep columns with duplicate tags --- sarracen/readers/read_phantom.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sarracen/readers/read_phantom.py b/sarracen/readers/read_phantom.py index 5b59a06..974b5b5 100644 --- a/sarracen/readers/read_phantom.py +++ b/sarracen/readers/read_phantom.py @@ -132,6 +132,14 @@ def _read_array_block(fp, df, n, nums, def_int_dtype, def_real_dtype): for j in range(nums[i]): tag = _read_fortran_block(fp, 16).decode('ascii').strip() + + if tag in df.columns: + count = 1 + original_tag = tag + while tag in df.columns: + count += 1 + tag = original_tag + f"_{count}" + data = np.frombuffer(_read_fortran_block(fp, dtype().itemsize * n), dtype=dtype) df[tag] = data