From 43d6635be0fc8cf139f90523e37962ef00f3fb7f Mon Sep 17 00:00:00 2001 From: gowthaman Date: Tue, 20 Jun 2023 08:56:32 +0530 Subject: [PATCH 1/2] format file --- main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/main.py b/main.py index 4e84b36..1817089 100644 --- a/main.py +++ b/main.py @@ -29,6 +29,7 @@ def make_archive(source: pathlib.Path, destination: pathlib.Path) -> None: base_dir = source.name shutil.make_archive(str(base_name), fmt, root_dir, base_dir) + class DBConn: def __init__(self): self.cur = None From b7668d19b9a2a1c32cb2f8d3b4cb126fc6ca8bdd Mon Sep 17 00:00:00 2001 From: gowthaman Date: Tue, 20 Jun 2023 09:01:16 +0530 Subject: [PATCH 2/2] format file --- main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 1817089..52004d5 100644 --- a/main.py +++ b/main.py @@ -99,7 +99,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", []) @@ -124,7 +124,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: @@ -190,9 +190,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)