Skip to content

Commit

Permalink
cove_rdls/process.py: Clean unflattened.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed (ODSC) committed Aug 22, 2023
1 parent 4d89269 commit da11fe7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cove_rdls/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ def is_processing_needed(self) -> bool:
self.data_filename
)

def _clean_json(self):
with open(os.path.join(output_dir, "unflattened.json"), "r+") as f:
json_data = json.loads(f.read())
json_data = {"datasets": [for dataset in json_data if len(dataset) > 0]}
f.seek(0)
f.write(json.dumps(json_data))
f.truncate()

def process(self, process_data: dict) -> dict:
if self.supplied_data.format != "spreadsheet":
return process_data
Expand Down Expand Up @@ -164,6 +172,8 @@ def process(self, process_data: dict) -> dict:

flattentool.unflatten(input_filename, **unflatten_kwargs)

self._clean_json()

return process_data

def get_context(self):
Expand Down

0 comments on commit da11fe7

Please sign in to comment.