tags:

views:

70

answers:

1

i have a CSV file :

COL1;COL2;COL3;COL4
1;1;;4
6;9;;0
9;8;;4

How do i fill in COL3 with a default value X?

so the result would be :

COL1;COL2;COL3;COL4
1;1;x;4
6;9;x;0
9;8;x;4

How can i achieve this using Powershell V2 or even ultra edit or Notepad++

Thanks

+1  A: 
Import-CSV -Path "input.csv" -Delimiter ';' | `
ForEach-Object { $_.COL3 = "x"; return $_ } | `
Export-CSV -Path "output.csv" -Delimiter ';' -NoTypeInformation
George Howarth
Instead of `; return $_`, `; $_` is sufficient.
Keith Hill
I know, but it's a better indication of what I mean.
George Howarth
@george: yes, but it's generally confusing to people new to the language. as a guideline, consider using return only without arguments, and only to exit early. frankly, I think the keyword should have been designed like that in the first place.functions/scriptblocks early ony.
x0n