-
Notifications
You must be signed in to change notification settings - Fork 1
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
6320085
commit e75ec7c
Showing
8 changed files
with
1,880 additions
and
114 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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
https://www.capterra.com/categories/ | ||
https://www.softwareadvice.com/categories/ | ||
https://sourceforge.net/software/ | ||
https://sourceforge.net/software/windows/ | ||
https://www.trustradius.com/categories | ||
https://www.getapp.com/browse/ | ||
https://sourceforge.net/software/ -out | ||
https://www.trustradius.com/categories out | ||
https://www.getapp.com/browse/ -out | ||
https://www.softwaresuggest.com/all-categories | ||
https://www.producthunt.com/categories | ||
https://clutch.co/sitemap | ||
https://clutch.co/sitemap -out | ||
|
||
|
||
|
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,41 @@ | ||
import os | ||
import json | ||
import boto3 | ||
from math import ceil | ||
import uuid | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
output_file = 'products.json' | ||
bucket_name = 'dinostomach' # Update with your AWS S3 bucket name | ||
folder_name = 'getapp' # Update with your desired folder name in S3 | ||
chunk_size = 1000 | ||
|
||
# Load existing data from the output_file | ||
if os.path.exists(output_file) and os.path.getsize(output_file) > 0: | ||
with open(output_file, 'r') as json_file: | ||
existing_data = json.load(json_file) | ||
|
||
total_items = len(existing_data) | ||
num_chunks = ceil(total_items / chunk_size) | ||
|
||
s3 = boto3.client('s3', | ||
aws_access_key_id=os.getenv('AWS_ACCESS_KEY_ID'), | ||
aws_secret_access_key=os.getenv('AWS_SECRET_ACCESS_KEY'), | ||
region_name=os.getenv('AWS_REGION')) | ||
|
||
for i in range(num_chunks): | ||
chunk = existing_data[i * chunk_size: (i + 1) * chunk_size] | ||
new_uuid = uuid.uuid4() | ||
chunk_file = f'products_chunk_{new_uuid}.json' | ||
|
||
# Save chunk to a separate JSON file | ||
with open(chunk_file, 'w') as chunk_json_file: | ||
json.dump(chunk, chunk_json_file, indent=4) | ||
|
||
# Upload the chunk file to S3 | ||
s3.upload_file(chunk_file, bucket_name, f'{folder_name}/{chunk_file}') | ||
|
||
# Remove the chunk file | ||
os.remove(chunk_file) |
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
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
Oops, something went wrong.