@@ -89,10 +89,15 @@ def execute(self, context):
8989 cursor .copy_expert (copy_command , csv_file )
9090 rows = cursor .rowcount
9191
92+ open_func = self ._get_open_func ()
93+ with open_func (self .csv_file_path , "rt" , encoding = "utf-8" ) as f :
94+ line_count = sum (1 for _ in f )
95+
9296 self .log .info (
93- "CSV saved: %s (%s rows, %s)" ,
97+ "CSV saved: %s (%s rows, %s lines, %s )" ,
9498 self .csv_file_path ,
9599 rows if rows >= 0 else "unknown" ,
100+ line_count ,
96101 "with header" if self .has_header else "no header" ,
97102 )
98103 return self .csv_file_path
@@ -159,7 +164,17 @@ def execute(self, context):
159164
160165 pg_hook = PostgresHook (postgres_conn_id = self .conn_id )
161166
162- self .log .info ("Loading %s into %s" , self .csv_file_path , self .table_name )
167+ open_func = self ._get_open_func ()
168+ with open_func (self .csv_file_path , "rt" , encoding = "utf-8" ) as f :
169+ line_count = sum (1 for _ in f )
170+
171+ self .log .info (
172+ "Loading %s (%s lines, %s) into %s" ,
173+ self .csv_file_path ,
174+ line_count ,
175+ "with header" if self .has_header else "no header" ,
176+ self .table_name ,
177+ )
163178
164179 column_clause = self ._build_column_clause ()
165180 header_clause = "HEADER" if self .has_header and not self .columns else ""
0 commit comments