powershell - Export csv spits out length only -
I can only get length when exporting to CSV, how it should be done properly.
$ redo = import-CSV c: \ temp \ testimport.txt | Group-Object Email | Foreach {"{0}, {1}" -f $ _ Name, (($ _GroupForch {$ _.Group}) -Join ',')} $ redo | Export-CSV c: \ temp \ test.csv -NoTypeInformation # "length" "46" "59" "110" "47" "149" "38" " 69 "" 32 "" 62 "" 29 "" 49 "" 31 "" 27 "" 48 "" 55 "" 42 "
Exports-CSV with the properties expects an object (or list of objects), while your command generates an array of pipeline strings. If you feed this array in Export-CSV , then CMDlet takes the properties of each given item (which is only length for strings) and output those properties Writes in the file. You need to create a list of items with the desired properties, such as:
import-csv c: \ temp \ testimport.txt` | Group-object email `| @ {N = "name"; E = {$ _. Name}}, @ {n = "group"; E = {($ _ group |% {$ _ group}) -sun ','}} `` | Export-CSV c: \ temp \ test.csv -NoTypeInformation
Comments
Post a Comment