diff --git a/main.py b/main.py index 8b69ece..ff7508e 100644 --- a/main.py +++ b/main.py @@ -105,7 +105,7 @@ class DBConn: clients = pd.read_sql(f"SELECT * FROM \"{tbl}\"", self.con) clients.to_csv(args.output / f"{prefix}{tbl}.csv", index=False, sep=args.delimiter) - def extract_child(self, items_list, current_level, prev_step, existing, step): + def extract_child(self, items_list, current_level, prev_step, existing): attributes = existing.get("attributes", [args.join_column]) flat_attributes = existing.get("flat_attributes", []) @@ -130,7 +130,7 @@ class DBConn: existing_next_step = children.get(subKey, {}) children[subKey] = self.extract_child(subValue, subKey, f"{prev_step}{current_level}_", - existing_next_step, step + 1) + existing_next_step) else: child_header = f"{current_level}_{subKey}" if child_header not in attributes: @@ -204,9 +204,10 @@ class DBConn: child_attribute = f"{key}_{subKey}" if child_attribute not in attributes: attributes.append(child_attribute) + elif value_is_list: existing = children.get(key, {}) - children[key] = self.extract_child(value, key, f"{top_level}_", existing, 1) + children[key] = self.extract_child(value, key, f"{top_level}_", existing) else: if key not in attributes: attributes.append(key)