aboutsummaryrefslogtreecommitdiffstats
path: root/gdpr_obfuscator/read.py
diff options
context:
space:
mode:
authorAlex Schofield <git@ajschof.me>2025-02-21 00:04:47 +0000
committerAlex Schofield <git@ajschof.me>2025-02-21 00:04:47 +0000
commit8465343ef01fd18fd753efa55d770e66addfb46f (patch)
tree64db91fd063ed6260d8a45ea6635b98ea3cf25bb /gdpr_obfuscator/read.py
parent6ebdc904eb48185c51c9deb4e426d56227646960 (diff)
downloadgdpr-obfuscator-8465343ef01fd18fd753efa55d770e66addfb46f.tar.gz
gdpr-obfuscator-8465343ef01fd18fd753efa55d770e66addfb46f.zip
remove all logging temporarily as it's being a pain
Diffstat (limited to 'gdpr_obfuscator/read.py')
-rw-r--r--gdpr_obfuscator/read.py36
1 files changed, 7 insertions, 29 deletions
diff --git a/gdpr_obfuscator/read.py b/gdpr_obfuscator/read.py
index 7f6372b..a486447 100644
--- a/gdpr_obfuscator/read.py
+++ b/gdpr_obfuscator/read.py
@@ -2,7 +2,6 @@ import csv
import io
import boto3
from typing import List, Dict
-from .utils import Utilities
class DataReader:
@@ -11,27 +10,21 @@ class DataReader:
the project completion, support for JSON/Parquet files will be added.
"""
- def __init__(self, log_level=None):
- self.utils = Utilities(self.log_level)
- self.log_level = log_level
- self.logger = self.utils.get_logger("CSVREADER", log_level)
+ def __init__(self):
+ pass
def read_local(self, path) -> List[Dict[str, str]]:
"""
A method to read a local CSV file and return the data as a list of
dictionaries.
"""
- self.logger.debug(f"Reading local CSV from: {path}")
try:
with open(path, mode="r", encoding="utf-8") as f:
reader = csv.DictReader(f)
return [dict(row) for row in reader]
- except FileNotFoundError:
- self.logger.error(f"File not found: {path}")
- raise
except Exception as e:
- self.logger.error(f"Error reading file: {e}")
+ pass
def read_s3(self, path) -> List[Dict[str, str]]:
"""
@@ -39,28 +32,13 @@ class DataReader:
and return the data as a list of dictionaries.
"""
bucket, key = self.utils.get_s3_path(path)
- self.logger.debug(f"Reading S3 CSV from: {bucket}/{key}")
client = boto3.client("s3")
- try:
- response = client.get_object(Bucket=bucket, Key=key)
- self.logger.info("S3 object read successfully")
- content = response["Body"].read().decode("utf-8")
- read_csv_content = self.read_string(content)
- return self.utils.create_byte_stream(read_csv_content)
- except client.exceptions.NoSuchKey:
- self.logger.error(f"Object not found: {bucket}/{key}")
- raise
- except client.exceptions.ClientError as e:
- self.logger.error(f"Error reading S3 object: {e}")
- raise
- except UnicodeDecodeError as e:
- self.logger.error(f"Error decoding S3 object: {e}")
- raise
- except Exception as e:
- self.logger.error(f"Error reading S3 object: {e}")
- raise
+ response = client.get_object(Bucket=bucket, Key=key)
+ content = response["Body"].read().decode("utf-8")
+ read_csv_content = self.read_string(content)
+ return self.utils.create_byte_stream(read_csv_content)
def read_string(self, content: str) -> List[Dict[str, str]]:
"""
git.ajschof.me — hosted by ajschofield — powered by cgit