@@ -18,6 +18,7 @@ class TableSupport(EncodingSupport, TempFileSupport):
1818 def emit_row_dicts (self , table , rows , headers = None ):
1919 csv_path = self .make_work_file (table .id )
2020 row_count = 0
21+ fragment_rows = []
2122 with open (csv_path , "w" , encoding = self .DEFAULT_ENCODING ) as fp :
2223 csv_writer = csv .writer (fp , dialect = "unix" )
2324 for row in rows :
@@ -28,11 +29,15 @@ def emit_row_dicts(self, table, rows, headers=None):
2829 if length == 0 :
2930 continue
3031 csv_writer .writerow (values )
31- self . manager . emit_text_fragment ( table , values , row_count )
32+ fragment_rows . append ( "," . join ([ v or "" for v in values ]) )
3233 row_count += 1
3334 if row_count > 0 and row_count % 1000 == 0 :
3435 log .info ("Table emit [%s]: %s..." , table , row_count )
36+ fragment_rows = []
37+ self .manager .emit_text_fragment (table , fragment_rows , row_count )
3538 if row_count > 0 :
39+ if len (fragment_rows ):
40+ self .manager .emit_text_fragment (table , fragment_rows , row_count )
3641 csv_hash = self .manager .store (csv_path , mime_type = CSV )
3742 table .set ("csvHash" , csv_hash )
3843 table .set ("rowCount" , row_count + 1 )
0 commit comments