I get a bunch of tab-delimited files and I want to convert them to comma-delimited files. I also need only two columns from the file "Date" and "Value1", so I drop the rest of the columns.
Date Value1 Value2 Value3 Value4 Sensor
08.07.2010 115,28 115,45 115,45 115,28 100
07.07.2010 115,34 115,32 115,34 115,25 85
06.07.2010 115,23 115,74 115,74 115,20 203
This works as follows:
(get-ChildItem -Path '*.txt').name | ForEach-Object {
Import-Csv -Path $_ -Delimiter "`t" |
Select-Object -Property Date,Value1 |
Export-Csv "out\$_"
}
Unfortunately in the source file a comma is used as decimal separator. So I get these files where Value1 is interpreted as string:
"Date","Value1"
"24.02.2017","30,18"
"23.02.2017","30,20"
"22.02.2017","30,18"
"21.02.2017","30,18"
"20.02.2017","30,17"
How can I set the data type of the column to numeric? During Import-CSV?