2016-05-24 40 views
1

我有一個PowerShell腳本解析CSV文件並添加一個新的值到特定的標題。例如輸入文件是一個頭,我想替換它下面的值。我已經添加了邏輯,它適用於正常的聽衆,但由於此標題有一個空間,我無法管理它。你能幫幫我,我怎麼能管理的空間PowerShell讀取空間的CSV標頭

轉換成CSV

Import-CSV $CSV_File | ForEach-Object { 
{$_.Input file} = "$machine_path\file" 
{$_.Output file} ="$machine_path\Output" 
$_ | Export-Csv $machine_path\new.csv -NoTypeInformation 
} 

回答

1

如果你想取消引用名稱中帶有空格,請使用引號的屬性:

Import-CSV $CSV_File | ForEach-Object { 
    $_.'Input file' = "$machine_path\file" 
    $_.'Output file' = "$machine_path\Output" 
    $_ 
}| Export-Csv $machine_path\new.csv -NoTypeInformation