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。 –