【发布时间】:2020-11-27 04:08:50
【问题描述】:
我有以下 JSON 文件(来自 Invoke-RestMethod 调用的示例输出)https://filebin.net/t3dtujxnssr6dcic/0.json?t=j2lr5rnb。我正在尝试运行 Powershell 命令将其导出到 CSV,但不断遇到错误,导致 CSV 为空或仅显示 SystemObject 的一行。
我知道 CSV 列的标题应该是:noticeId,title,solicitationNumber,department,subTier,office,postedDate,type,baseType,archiveType,archiveDate,typeOfSetAsideDescription,typeOfSetAside,responseDeadLine,naicsCode,classificationCode,active,award, pointOfContact,description,organizationType,officeAddress,placeOfPerformance,additionalInfoLink,uiLink,links/0,resourceLinks
我的命令是:
((Get-Content -Path $getpath) | ConvertFrom-Json).results | Export-CSV -Path $topath -NoTypeInformation
我最终得到以下错误:
Export-Csv : Cannot bind argument to parameter 'InputObject' because it is null.
At line:1 char:61
+ ... nvertFrom-Json).results | Export-CSV -Path $topath -NoTypeInformation
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Export-Csv], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ExportCsvCo
mmand
谢谢,
【问题讨论】:
-
你能发布
((Get-Content -Path $getpath) | ConvertFrom-Json).results的输出吗?根据错误,它似乎是空的 -
你的
.results来自哪里?从您的数据文件看来,您应该改用.opportunitiesData...
标签: json excel powershell csv