Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用powershell将特定列从csv文件复制到另一个具有特定单词位置的文件_Powershell_Powershell 2.0_Powershell 3.0_Azure Powershell - Fatal编程技术网

使用powershell将特定列从csv文件复制到另一个具有特定单词位置的文件

使用powershell将特定列从csv文件复制到另一个具有特定单词位置的文件,powershell,powershell-2.0,powershell-3.0,azure-powershell,Powershell,Powershell 2.0,Powershell 3.0,Azure Powershell,我是PowerShell的新手这是我开始使用它的一天,我需要一些关于为我的模型构建脚本的帮助。这些是步骤 我正在获取文件内容,并已获取不同变量中的所有内容,如: $Test_Name、$Test_number、$Result并将数据从CSV导入以下变量: 。。。。等等 现在,我将数据保存到一些powershell变量中,现在我希望这些变量内容能够粘贴到另一个名为output.txt/docs的文件中,这些文件基于若干特定参数,如%%PasteHereTestName%%、%%PasteHereT

我是PowerShell的新手这是我开始使用它的一天,我需要一些关于为我的模型构建脚本的帮助。这些是步骤

  • 我正在获取文件内容,并已获取不同变量中的所有内容,如: $Test_Name、$Test_number、$Result并将数据从CSV导入以下变量:
  • 。。。。等等

  • 现在,我将数据保存到一些powershell变量中,现在我希望这些变量内容能够粘贴到另一个名为output.txt/docs的文件中,这些文件基于若干特定参数,如%%PasteHereTestName%%、%%PasteHereTestNumber%%
  • 有谁能在这方面指导我吗?我已经尝试了几种方法,但似乎我需要一些指导


    **Azure devops管道将使用它将内容从测试文件复制到输出文档文件。

    将CSV导入到变量中,您可以直接寻址每个属性,并通过包含select object语句将单个列/属性写入新的CSV文件

    $Results = Import-csv c:\temp\testfile.csv
    $results | select-object Column1, Column2, Column3 | export-csv C:\temp\proddata.csv
    
    您说您“尝试了多种方法”,但没有提供代码片段。请以简单明了的方式总结您的问题,解释您想做什么,以及您用一些示例代码尝试了什么。请看一下这本书。
    $Results = Import-csv c:\temp\testfile.csv
    $results | select-object Column1, Column2, Column3 | export-csv C:\temp\proddata.csv