Delete first two columns in CSV with PowerShell -
i need delete first 2 columns in csv. not know header names, not static. figured out how remove first 2 rows, not first 2 columns. sample code working below
$csv = import-csv 'input.csv' $headers = $csv[0].psobject.properties | select -expand name $step = 4 ($i = 0; $i -lt $headers.count; $i += $step) { $csv | select $headers[$i..($i+$step-1)] | export-csv "output_$($i/$step).csv" -notype }
this seems work:
$csv = import-csv 'input.csv' $include = $csv[0].psobject.properties | select -expandproperty name -skip 2 $csv | select $include -skip 2 | export-csv output.csv -notypeinformation
that should take care of pruning off first 2 columns , skipping first 2 rows.
Comments
Post a Comment