File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 11from dataclasses import dataclass
22import pandas
3+ import os
34
45import process_report .util as util
56
@@ -122,3 +123,20 @@ def export(self):
122123 def export_s3 (self , s3_bucket ):
123124 s3_bucket .upload_file (self .output_path , self .output_s3_key )
124125 s3_bucket .upload_file (self .output_path , self .output_s3_archive_key )
126+
127+ def fetch (self , s3_bucket = None ):
128+ """Fetches the exported invoice CSV from S3 and loads it into self.data.
129+
130+ If s3_bucket is not provided, uses the default invoice bucket.
131+ The CSV is downloaded to the current working directory using its base filename.
132+ """
133+ s3_key = self .output_s3_key
134+ local_filename = os .path .basename (s3_key )
135+
136+ if s3_bucket is None :
137+ # Fallback to default bucket utility which also downloads
138+ util .fetch_s3 (s3_key )
139+ else :
140+ s3_bucket .download_file (s3_key , local_filename )
141+
142+ self .data = pandas .read_csv (local_filename )
You can’t perform that action at this time.
0 commit comments