aboutsummaryrefslogtreecommitdiffstats
path: root/obfuscator/csv_reader.py
diff options
context:
space:
mode:
authorAlex Schofield <git@ajschof.me>2025-02-17 01:06:08 +0000
committerAlex Schofield <git@ajschof.me>2025-02-17 01:06:08 +0000
commitc03897d446352c461790ab82c7a2bae85db17e86 (patch)
tree8fae47796396dc952e79645f8e8db3fddcb5bd89 /obfuscator/csv_reader.py
parentc8df3c6d06dcb2ba6720a17bf3b6db67693c41dd (diff)
downloadgdpr-obfuscator-c03897d446352c461790ab82c7a2bae85db17e86.tar.gz
gdpr-obfuscator-c03897d446352c461790ab82c7a2bae85db17e86.zip
add method for reading csv content directly from string
Diffstat (limited to 'obfuscator/csv_reader.py')
-rw-r--r--obfuscator/csv_reader.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/obfuscator/csv_reader.py b/obfuscator/csv_reader.py
index cbd18c1..cf81a30 100644
--- a/obfuscator/csv_reader.py
+++ b/obfuscator/csv_reader.py
@@ -1,4 +1,5 @@
import csv
+import io
from typing import List, Dict
from obfuscator.logger import get_logger
@@ -28,3 +29,11 @@ class CSVReader:
def read_s3(self) -> List[Dict[str, str]]:
return []
+
+ def read_string(self, content: str) -> List[Dict[str, str]]:
+ if not content.strip():
+ return []
+
+ f = io.StringIO(content)
+ reader = csv.DictReader(f)
+ return [dict(row) for row in reader]
git.ajschof.me — hosted by ajschofield — powered by cgit