Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
5ceecc6bf4
7
main.py
7
main.py
@ -105,7 +105,7 @@ class DBConn:
|
|||||||
clients = pd.read_sql(f"SELECT * FROM \"{tbl}\"", self.con)
|
clients = pd.read_sql(f"SELECT * FROM \"{tbl}\"", self.con)
|
||||||
clients.to_csv(args.output / f"{prefix}{tbl}.csv", index=False, sep=args.delimiter)
|
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])
|
attributes = existing.get("attributes", [args.join_column])
|
||||||
flat_attributes = existing.get("flat_attributes", [])
|
flat_attributes = existing.get("flat_attributes", [])
|
||||||
@ -130,7 +130,7 @@ class DBConn:
|
|||||||
existing_next_step = children.get(subKey, {})
|
existing_next_step = children.get(subKey, {})
|
||||||
children[subKey] = self.extract_child(subValue, subKey,
|
children[subKey] = self.extract_child(subValue, subKey,
|
||||||
f"{prev_step}{current_level}_",
|
f"{prev_step}{current_level}_",
|
||||||
existing_next_step, step + 1)
|
existing_next_step)
|
||||||
else:
|
else:
|
||||||
child_header = f"{current_level}_{subKey}"
|
child_header = f"{current_level}_{subKey}"
|
||||||
if child_header not in attributes:
|
if child_header not in attributes:
|
||||||
@ -204,9 +204,10 @@ class DBConn:
|
|||||||
child_attribute = f"{key}_{subKey}"
|
child_attribute = f"{key}_{subKey}"
|
||||||
if child_attribute not in attributes:
|
if child_attribute not in attributes:
|
||||||
attributes.append(child_attribute)
|
attributes.append(child_attribute)
|
||||||
|
|
||||||
elif value_is_list:
|
elif value_is_list:
|
||||||
existing = children.get(key, {})
|
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:
|
else:
|
||||||
if key not in attributes:
|
if key not in attributes:
|
||||||
attributes.append(key)
|
attributes.append(key)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user