-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34dc192
commit 11b4606
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#JSONCombiner.py | ||
#if running twice in same day, make sure to | ||
|
||
import os | ||
import json | ||
from datetime import datetime | ||
|
||
folder_path = "Files" | ||
|
||
# List all files in the folder | ||
files = os.listdir("Files") | ||
|
||
python_objects = [] | ||
|
||
|
||
# Loop through each file | ||
for file_name in files: | ||
# Check if it's a file (not a subdirectory) | ||
if os.path.isfile(os.path.join(folder_path, file_name)) and file_name.endswith('.json'): | ||
# Process the file as needed | ||
print(f"Processing file: {file_name}") | ||
|
||
# Example: Read the content of the file | ||
with open(os.path.join(folder_path, file_name), 'r') as file: | ||
python_objects.append(json.load(file)) | ||
|
||
# Dump all the Python objects into a single JSON file. | ||
with open(os.path.join(f"combined_{datetime.now().strftime('%Y-%m-%d')}.json"), "w") as f: | ||
json.dump(python_objects, f, indent=4) |