From 1ea412980aebed60f215001ae2d8cbbf42a3716c Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Thu, 20 Feb 2025 23:54:30 +0000 Subject: update read.py --- gdpr_obfuscator/read.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'gdpr_obfuscator/read.py') diff --git a/gdpr_obfuscator/read.py b/gdpr_obfuscator/read.py index 752c7fd..7f6372b 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 .logger import get_logger from .utils import Utilities @@ -13,8 +12,9 @@ class DataReader: """ def __init__(self, log_level=None): + self.utils = Utilities(self.log_level) self.log_level = log_level - self.logger = get_logger("CSVREADER", log_level) + self.logger = self.utils.get_logger("CSVREADER", log_level) def read_local(self, path) -> List[Dict[str, str]]: """ @@ -38,8 +38,7 @@ class DataReader: A method to read an S3 object containing CSV data and return the data as a list of dictionaries. """ - utils = Utilities(self.log_level) - bucket, key = utils.get_s3_path(path) + bucket, key = self.utils.get_s3_path(path) self.logger.debug(f"Reading S3 CSV from: {bucket}/{key}") client = boto3.client("s3") @@ -49,7 +48,7 @@ class DataReader: self.logger.info("S3 object read successfully") content = response["Body"].read().decode("utf-8") read_csv_content = self.read_string(content) - return utils.create_byte_stream(read_csv_content) + return self.utils.create_byte_stream(read_csv_content) except client.exceptions.NoSuchKey: self.logger.error(f"Object not found: {bucket}/{key}") raise -- cgit v1.2.3