File tree Expand file tree Collapse file tree 1 file changed +1
-5
lines changed
Expand file tree Collapse file tree 1 file changed +1
-5
lines changed Original file line number Diff line number Diff line change 44import json
55from csv import DictReader
66from io import BytesIO , TextIOWrapper
7- from botocore .response import StreamingBody
87from clients import s3_client , lambda_client , logger
98from constants import SOURCE_BUCKET_NAME , FILE_NAME_PROC_LAMBDA_NAME
109
@@ -19,10 +18,7 @@ def get_environment() -> str:
1918def get_csv_content_dict_reader (file_key : str ) -> DictReader :
2019 """Returns the requested file contents from the source bucket in the form of a DictReader"""
2120 response = s3_client .get_object (Bucket = SOURCE_BUCKET_NAME , Key = file_key )
22- s3_object_body : StreamingBody = response ["Body" ]
23- # Try to seek, otherwise fallback to creating 2 objects
24- # Should test in real AWS in addition to moto
25- s3_object_bytes_io = BytesIO (s3_object_body .read ())
21+ s3_object_bytes_io = BytesIO (response ["Body" ].read ())
2622 encoding = "utf-8" if is_utf8 (s3_object_bytes_io , file_key ) else "windows-1252"
2723 text_io = TextIOWrapper (s3_object_bytes_io , encoding = encoding , newline = "" )
2824 return DictReader (text_io , delimiter = "|" )
You can’t perform that action at this time.
0 commit comments