是否可以将 csv 文件导入 powershell,用一组定义的数据替换整个标题行,然后用新名称保存到 csv 文件。
我需要能够自动执行此任务,以便其他软件可以使用它。
任何想法将不胜感激。
最佳答案
示例文件内容
1,b,4
8,j,7
8,k,9
制作自己的标题:
Import-Csv D:\Temp\txt.txt -Header "name","letter","value"
name letter value
---- ------ -----
1 b 4
8 j 7
8 k 9
跳过行:
Import-Csv D:\Temp\txt.txt -Header "name","letter","value" | select -skip 1
name letter value
---- ------ -----
8 j 7
8 k 9
将其全部与导出联系起来:
$tempCSV = Import-Csv D:\Temp\txt.txt -Header "name","letter","value" | select -skip 1
$tempCSV | Export-CSV D:\Temp\txt.txt -NoTypeInformation
关于powershell - 用 powershell 替换 csv 文件标题行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24793625/