From 58a672a6803ea9752cd695c5826777dc4425b323 Mon Sep 17 00:00:00 2001 From: nuluh Date: Tue, 17 Jun 2025 13:20:27 +0700 Subject: [PATCH] fix(data): Fix generate_df_tuples function output bug when special_groups args is passed --- data/QUGS/convert.py | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/data/QUGS/convert.py b/data/QUGS/convert.py index d291a88..d0788f8 100644 --- a/data/QUGS/convert.py +++ b/data/QUGS/convert.py @@ -71,30 +71,29 @@ def generate_df_tuples(total_dfs=30, group_size=5, prefix="zzzAD", ext="TXT", fi df_name = f"{prefix}{i}.{ext}" tuples.append((df_name, [first_col, last_col])) - # tuples.append(list) - # Add special groups at specified positions (other than beginning) - if special_groups: - for group in special_groups: - position = group.get('position', 0) # default value is 0 if not specified - if position > 0: - df_name = group['df_name'] - size = group.get('size', group_size) - - # Create the special group tuples - special_tuples = [] - for i in range(1, size + 1): - first_col = first_col_start + i - 1 - last_col = first_col + last_col_offset - special_tuples.append((df_name, [first_col, last_col])) - - tuples.insert(special_tuples) - if group: # Group tuples into sublists of group_size grouped_tuples = [] for i in range(0, len(tuples), group_size): grouped_tuples.append(tuples[i:i + group_size]) - return grouped_tuples + tuples = grouped_tuples + # tuples.append(list) + # Add special groups at specified positions (other than beginning) + if special_groups: + for group in special_groups: + position = group.get('position', 0) # default value is 0 if not specified + df_name = group['df_name'] + size = group.get('size', group_size) + + # Create the special group tuples + special_tuples = [] + for i in range(size): + first_col = first_col_start + i + last_col = first_col + last_col_offset + special_tuples.append((df_name, [first_col, last_col])) + + tuples.insert(position, special_tuples) + return tuples @@ -273,7 +272,7 @@ class DataProcessor: :param output_dir: Directory to save the CSV files. :param file_prefix: Prefix for the output filenames. """ - for group_idx, group in enumerate(self.data, start=1): + for group_idx, group in enumerate(self.data, start=0): group_folder = os.path.join(output_dir, f"{file_prefix}_{group_idx}") os.makedirs(group_folder, exist_ok=True) for test_idx, df in enumerate(group, start=1):