From 78b18bb9effde45e9f104ec6b5add6eb149d0fe9 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Fri, 21 Feb 2025 02:36:13 +0000 Subject: don't create byte stream in read methods --- gdpr_obfuscator/read.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/gdpr_obfuscator/read.py b/gdpr_obfuscator/read.py index a486447..d51c6f3 100644 --- a/gdpr_obfuscator/read.py +++ b/gdpr_obfuscator/read.py @@ -19,12 +19,8 @@ class DataReader: dictionaries. """ - try: - with open(path, mode="r", encoding="utf-8") as f: - reader = csv.DictReader(f) - return [dict(row) for row in reader] - except Exception as e: - pass + with open(path, mode="r", encoding="utf-8") as f: + return self.read_string(f.read()) def read_s3(self, path) -> List[Dict[str, str]]: """ @@ -38,7 +34,7 @@ class DataReader: 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) + return read_csv_content def read_string(self, content: str) -> List[Dict[str, str]]: """ -- cgit v1.2.3