$path = "c:\Users\scans\Downloads\wspolnie_openg.sql"
$l = [System.IO.File]::ReadAllLines($path)
$enc = [System.Text.Encoding]::UTF8
$sz = 0
$tgt = 1950 * 1024
$split = -1
for ($i=0;$i -lt $l.Count;$i++) {
    $line = $l[$i] + "`r`n"
    $sz += $enc.GetByteCount($line)
    if ($sz -gt $tgt) {
        for ($j=$i;$j -ge 0;$j--) {
            if ($l[$j].TrimEnd().EndsWith(';')) { $split = $j; break }
        }
        break
    }
}
if ($split -ne -1) {
    Write-Host "End Part 1 Line: $($split + 1)"
    Write-Host "Start Part 2 Line: $($split + 2)"
    Write-Host "Context:"
    for($k=($split-2);$k -le ($split+2);$k++) {
        $p = if($k -eq $split){">>>"}else{"   "}
        Write-Host "$p $($k+1): $($l[$k])"
    }
    $p1Size = 0
    for ($i = 0; $i -le $split; $i++) { $p1Size += $enc.GetByteCount($l[$i] + "`r`n") }
    Write-Host "Estimated Size: $([Math]::Round($p1Size / 1024, 2)) KB"
}
