【问题标题】:When using export-csv my special character is showing as an ?. Is it possible to bulk remove the special character?使用 export-csv 时,我的特殊字符显示为 ?。是否可以批量删除特殊字符?
【发布时间】:2020-01-31 16:25:19
【问题描述】:

运行以下代码时:

$folderPath = '\\dc1\shared\BI\HisRms\'

$folderPathDest = 'C:\Users\jonathon.kindred\Desktop\RM2\'


$Columns = 'SKU', 'Landed Cost',  'Current Std Price',  'Current Sale Price',  'Free Stock',  'Markdown',  'Published Calc'


Get-ChildItem $folderPath -Name |


ForEach-Object { 


    $filePath = $folderPath + $_


    $filePathdest = $folderPathDest + $_


    Import-Csv $filePath | Select $Columns |
    Export-Csv -Path $filePathDest
}

“到岸成本”、“当前标准价格”、“当前销售价格”以 ?例如?12.00.

我只想在导出期间从这些列中删除 £ 符号,所以我只有十进制值。有谁知道我会怎么做?

【问题讨论】:

  • ... |Export-Csv -Path $filePathDest -Encoding unicode

标签: powershell special-characters export-csv


【解决方案1】:

您可以像这样批量删除特殊字符 £:

$csv = Import-Csv $filePath | Select $Columns
$csv | Export-csv $FilePathDesc -Encoding Unicode

特殊字符是井号,编码是Unicode。

【讨论】:

  • 这不起作用抱歉,它对我的​​数据执行以下操作:``` SKU,"Landed Cost","Current Std Price","Current Sale Price","Free Stock", “降价”,“已发布计算”S18W-1000023452-LRD,“�6.50”,“�20.00”,“�20.00”,“86”,“否”,“发布”S17W-1300003383-WTE,“�9.50” ,"�25.00","�25.00","136","否","已发布" S18W-2800023541-WTE,"�7.25","�18.00","�18.00","61","否" "已发布" S18W-2800023540-BCK,"�5.25","�18.00","�18.00","68","否","已发布"
  • export-csv在ps 5中默认编码为ascii。
【解决方案2】:

另外:当您在输出中看到 ? 时,这意味着当前正在使用的字符集在您的终端上显示它 无法识别它是 Unicode。或者它可能有,但它没有那个特定字符的代码点。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-01
    • 1970-01-01
    • 2014-05-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多