I'm having problems trying to pull thousands separators from some currency values ββinto a set of files. Bad values ββare separated by commas and double quotes. There are other values ββthat are <$ 1000 that do not present a problem.
An example of an existing file:
"12,345.67",12.34,"123,456.78",1.00,"123,456,789.12"
Example of the desired file (thousands separators removed):
"12345.67",12.34,"123456.78",1.00,"123456789.12"
I found a regex expression to match numbers with delimiters that work fine, but I'm having problems with the -replace operator. I am replaced by replacement cost. I read about $ & and I wonder if I will use it here. I tried $ _, but that pulls ALL my commas. Should I use $ matches in some way?
Here is my code:
$Files = Get-ChildItem *input.csv foreach ($file in $Files) { $file | Get-Content |
source share