1
因此,我有这个导入csv文件的powershell脚本,将null替换为'0'并导出此csv。将CSV内容编码为UTF-8
的问题是,这个CSV的内容和标题是希伯来语
我几乎尝试使用-Encoding为所有类型的编码,但没有
任何建议的一切 ?
$propertyTranslation = @(
@{ Name = 'Customer__c'; Expression = { $_.'לקוח' } }
@{ Name = 'Name__c'; Expression = { $_.'שם' } }
@{ Name = 'CheckCount__c'; Expression = { $_.'כמות' } }
@{ Name = 'Deal'; Expression = { $_.'עסקהוזה' } }
@{ Name = 'Amount__c'; Expression = { $_.'סכום' } }
@{ Name = 'Discount__c'; Expression = { $_.'ניסיון' } }
# And so on
)
$csv = Import-Csv C:\Users\alon\Documents\again.csv -Header "Customer__c","Name__c","Deal","Amount__c","CheckCount__c","Discount__c"
$csv | ForEach-Object {
if($_.Customer__c -eq "") { $_.Customer__c = "0" }
if($_.Name__c -eq "") { $_.Name__c = "0" }
if($_.Deal -eq "") { $_.Deal = "0" }
if($_.Amount__c -eq "") { $_.Amount__c = "0" }
if($_.Discount__c -eq "") { $_.Discount__c = "0" }
if($_.CheckCount__c -eq "") { $_.CheckCount__c = "0" }
}
Select-Object -Property $propertyTranslation
$csv | Export-Csv C:\Users\alon\Documents\CheckDealBeforeUpsert.csv -NoTypeInformation -Encoding UTF8
你'$ propertyTranslation'类型是'system.array';请考虑一个[哈希表](https://technet.microsoft.com/en-us/library/ee692803.aspx),而不是像'$ propertyTranslation = @ {0} {Customer__c'='לקוח'; 'Name__c'='שם'; 'CheckCount__c'='כמות'; 'Deal'='עסקהוזה'; 'Amount__c'='סכום'; 'Discount__c'='ניסיון' }'。但是,如果您完全忽略'$ propertyTranslation',我会说您的脚本可以工作。 – JosefZ
好的,谢谢你的feedvak –
你可以看到我的代码(最后一行有点右)我尝试使用-Encoding。 –