在powershell中将行添加到CSV文件 [英] Add rows to CSV File in powershell
本文介绍了在powershell中将行添加到CSV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试找出如何向带有标题的csv文件添加一行。
我使用以下内容获取内容:
$ fileContent = Import-csv $ file -headerDate,
$ File
日期,说明
pre>
Text1,text2
text3,text4
如何追加一个新的日期和描述的行。对不起我对powershell比较新。感谢任何人可以帮助
解决方案创建一个新的自定义对象并将其添加到
Import-Csv
创建。$ fileContent = Import-csv $ file -headerDate Description
$ newRow = New-Object PsObject -Property @ {Date ='Text4'; Description ='Text5'}
$ fileContent + = $ newRow
Trying to figure out how to add a row to a csv file with titles. I get the content using:
$fileContent = Import-csv $file -header "Date", "Description"
$File
returnsDate,Description Text1,text2 text3,text4
How do I append a row with a new date and description. Sorry I am relatively new to powershell. thanks to anyone that can help
解决方案Create a new custom object and add it to the object array that
Import-Csv
creates.$fileContent = Import-csv $file -header "Date", "Description" $newRow = New-Object PsObject -Property @{ Date = 'Text4' ; Description = 'Text5' } $fileContent += $newRow
这篇关于在powershell中将行添加到CSV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文