Skip to content

Commit

Permalink
Moved merged tables to a dict to improve file naming, making it easie…
Browse files Browse the repository at this point in the history
…r to find the data.
  • Loading branch information
dominikzorgnotti committed Mar 14, 2021
1 parent 0a02122 commit 5abd38c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions data_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def create_json_output(kb_dataobject, output_base_dir: str, record_type: str):
table_id += 1
if kb_dataobject.list_of_merged_frames:
table_id = 0
for dataframe in kb_dataobject.list_of_merged_frames:
filename = f"kb{kb_dataobject.id}_{kb_dataobject.fmt_product}_merged{table_id}_release_as-{record_type}.json"
for table_name, dataframe in kb_dataobject.list_of_merged_frames.items():
filename = f"kb{kb_dataobject.id}_{kb_dataobject.fmt_product}_{table_name}_as-{record_type}.json"
if "Build Number" in dataframe.columns and record_type == "index":
dataframe = transform_index(dataframe)
try:
Expand All @@ -60,8 +60,6 @@ def create_json_output(kb_dataobject, output_base_dir: str, record_type: str):
)
except ValueError as err:
print(f"{kb_dataobject.id}: Error for json {record_type} in merged table {table_id}: {err}")
finally:
table_id += 1


def transform_index(dataframe):
Expand Down
8 changes: 4 additions & 4 deletions kb_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def transform_kb2143838(self, dataframe):
def merge_tables_kb2143838(self):
"""Accepts a list of dataframes, merge them and return a list of the merged df"""
# Return this list when ready
merged_vcenter_tables = []
merged_vcenter_tables = {}
# Prepare the tables
vc7x_vcsa = self.list_of_dframes[0]
vc67_vcsa = self.list_of_dframes[1]
Expand All @@ -188,15 +188,15 @@ def merge_tables_kb2143838(self):
# Merge VCSA tables
merged_vcsa_builds = vc7x_vcsa.append(vc67_vcsa)
merged_vcsa_builds.reset_index(drop=True, inplace=True)
merged_vcenter_tables.append(merged_vcsa_builds)
merged_vcenter_tables["vcsa_builds"] = merged_vcsa_builds
# Merge vCenter for Windows tables
merged_windows_builds = vc67_win.append(vc_le65)
merged_windows_builds.reset_index(drop=True, inplace=True)
merged_vcenter_tables.append(merged_windows_builds)
merged_vcenter_tables["windows_vc_builds"] = merged_windows_builds
# Merge both tables
merged_vc_all_builds = merged_vcsa_builds.append(merged_windows_builds)
merged_vc_all_builds.reset_index(drop=True, inplace=True)
merged_vcenter_tables.append(merged_vc_all_builds)
merged_vcenter_tables["all_vcenter_builds"] = merged_vc_all_builds
# Return the list
return merged_vcenter_tables

Expand Down

0 comments on commit 5abd38c

Please sign in to comment.