-
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
ab33dda
commit bcaa252
Showing
8 changed files
with
50 additions
and
4 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
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
Binary file not shown.
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 |
---|---|---|
|
@@ -65,6 +65,8 @@ services: | |
environment: | ||
PGADMIN_DEFAULT_EMAIL: [email protected] | ||
PGADMIN_DEFAULT_PASSWORD: admin | ||
networks: | ||
- data-network | ||
|
||
redis: | ||
image: redis:latest | ||
|
@@ -216,6 +218,7 @@ services: | |
- ./logs:/sources/logs | ||
- ./plugins:/sources/plugins | ||
- ./config:/sources/config | ||
- ./data:/sources/data | ||
|
||
volumes: | ||
pgdata: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pandas as pd | ||
from sqlalchemy import create_engine | ||
|
||
from config.settings import POSTGRES_CONN_STRING | ||
|
||
engine = create_engine(POSTGRES_CONN_STRING) | ||
|
||
|
||
def process_data(csv_file_path, table_name, selected_columns, chunk_size=1000): | ||
try: | ||
chunks = pd.read_csv( | ||
csv_file_path, chunksize=chunk_size, usecols=selected_columns | ||
) | ||
for chunk in chunks: | ||
chunk.to_sql( | ||
name=table_name, | ||
con=engine, | ||
if_exists="append", | ||
index=False, | ||
) | ||
print( | ||
f"Data from {csv_file_path} successfully loaded into {table_name}." | ||
) | ||
except Exception as e: | ||
print(f"Error occurred: {e}") | ||
|
||
|
||
def transform_product_data(): | ||
process_data( | ||
"data/amazon-sale-report.csv", | ||
"products", | ||
["SKU", "Style", "Category", "Size", "ASIN"], | ||
) |
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