scripting - removing extra spaces in powershell -
scripting - removing extra spaces in powershell -
i'd utilize powershell remove superfluous spaces , replace them single comma between entries can convert result working csv farther analysis.
here code;
get-content –path c:\users\username\desktop\results.txt| foreach-object {$_ -replace "\s+" " " } | out-file -filepath c:\users\username\desktop\results.csv
in text file initial resuts
entry entry entry (all separated 5 spaces)
what wan this
entry,entry,entry
so excel set them in separate cells
thank time
you close needed replace ","
instead of " "
. lets assume text files lines following. dont know if meant leading/trailing space there thats ok.
" entry entry entry "
get-content –path c:\users\username\desktop\results.txt| foreach-object {$_.trim() -replace "\s+" "," } | out-file -filepath c:\users\username\desktop\results.csv -encoding ascii
$_.trim() -replace "\s+" ","
utilize trim remove outer spaces prevent values in csv in case.
let me know if misinterpeted question.
powershell scripting
Comments
Post a Comment