@@ -109,7 +109,7 @@ def __init__(
109109 postgres_dsn : str ,
110110 table : str , # e.g. "wfr26"
111111 dbc_path : Optional [str ] = None ,
112- batch_size : int = 5000 ,
112+ batch_size : int = 500 ,
113113 ):
114114 self .postgres_dsn = postgres_dsn
115115 self .table = table .lower () # Postgres names are lowercase
@@ -478,7 +478,7 @@ async def stream_multiple_csvs(
478478 f .write (data )
479479 print (f"💾 Saved { filename } ({ len (data ):,} bytes)" )
480480
481- # Fast line-count pre-scan (no CSV parse, no DBC decode )
481+ # Count rows for progress (yields control briefly between files )
482482 print ("🔢 Counting rows for progress tracking…" )
483483 total_rows = 0
484484 for csv_path , filename in _iter_csv_files_under_dir (temp_dir ):
@@ -487,8 +487,17 @@ async def stream_multiple_csvs(
487487 except ValueError :
488488 continue
489489 try :
490- with open (csv_path , "rb" ) as f :
491- total_rows += sum (1 for _ in f )
490+ with open (csv_path , "r" , encoding = "utf-8" , errors = "replace" ) as f :
491+ for row in csv .reader (f ):
492+ if len (row ) < 11 or not row [0 ]:
493+ continue
494+ try :
495+ bvs = [int (b ) for b in row [3 :11 ] if b ]
496+ if len (bvs ) == 8 :
497+ int (row [2 ])
498+ total_rows += 1
499+ except Exception :
500+ pass
492501 except Exception :
493502 pass
494503 await asyncio .sleep (0 ) # yield to event loop
0 commit comments