如何使用 Powershell 脚本将 csv 转换为小写
How to convert the csv to lower case using Powershell script
我写了下面的代码来将 csv 转换为小写。
(Get-Content "$file" -Raw).ToLower() | Out-File "$outfile"
但是出现 错误 比如:
Get-Content : A parameter cannot be found that matches parameter name 'Raw'.
-Raw
已添加到 PowerShell 3.0。如果您使用的是 2.0 或更低版本,则它不存在。相反,你可以这样做:
[System.IO.File]::ReadAllText($file)
作为 的替代方法,将 Get-Content
的输出通过管道传输到 ForEach-Object
并在每一行上调用 ToLower()
:
Get-Content $file |ForEach-Object { $_.ToLower() } |Out-File $outfile
或者,在 PowerShell 3.0 及更高版本中:
Get-Content $file |ForEach-Object ToLower |OutFile $outfile
我写了下面的代码来将 csv 转换为小写。
(Get-Content "$file" -Raw).ToLower() | Out-File "$outfile"
但是出现 错误 比如:
Get-Content : A parameter cannot be found that matches parameter name 'Raw'.
-Raw
已添加到 PowerShell 3.0。如果您使用的是 2.0 或更低版本,则它不存在。相反,你可以这样做:
[System.IO.File]::ReadAllText($file)
作为 Get-Content
的输出通过管道传输到 ForEach-Object
并在每一行上调用 ToLower()
:
Get-Content $file |ForEach-Object { $_.ToLower() } |Out-File $outfile
或者,在 PowerShell 3.0 及更高版本中:
Get-Content $file |ForEach-Object ToLower |OutFile $outfile