【发布时间】:2014-06-20 16:17:32
【问题描述】:
我正在尝试将多个 CSV 文件合并到一个大型 CSV 文件中。我编写了一个 powershell 脚本,它成功地为每个标签名称创建了单独的 csv 文件。但是当最后添加Get-Content 时,我得到了这个错误:
Get-Content : An object at the specified path C:\HTD2CSV\Output_Files\*.CSV does not exist, or has been filtered by the
-Include or -Exclude parameter.
At C:\HTD2CSV\extract.ps1:30 char:20
+ $temp = Get-Content <<<< "$destinationPath\*.CSV" #| Set-Content $destinationPath\merged.CSV
+ CategoryInfo : ObjectNotFound: (System.String[]:String[]) [Get-Content], Exception
+ FullyQualifiedErrorId : ItemNotFound,Microsoft.PowerShell.Commands.GetContentCommand
但我已经在 Output_Files 文件夹中有 CSV 文件。输入Get-Content .\Output_Files\*.CSV 在命令行上运行良好,但显然不是在脚本中。我的代码如下所示:
$currentPath = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)
$sourcePath = "C:\Program Files (x86)\Proficy\Proficy iFIX\HTRDATA"
$destinationPath = "$currentPath\Output_Files"
@(
"PPP_VE0963A",
"PPP_VE0963B",
"PPP_VE0964A",
"PPP_VE0964B",
"PPP_VE0967A",
"PPP_VE0967B",
"PPP_ZE0963A",
"PPP_ZE0963B",
"PPP_ZE0964A",
"PPP_ZE0964B"
) | ForEach-Object {
.\HTD2CSV.exe `
PPP:$_.F_CV `
/dur:00:23:59:00 `
/int:00:01:00 `
/sd:05/01/14 `
/st:00:00:00 `
/sp:$sourcePath `
/dp:$destinationPath\$_.CSV `
/dtf:0 `
/dbg:0
}
Get-Content "$destinationPath\*.CSV" | Set-Content "$destinationPath\merged.CSV"
【问题讨论】:
标签: powershell csv