我有很多文件,我想从每个文件中读取一个特定的列,然后将每个文件输出到一个新的csv文件,每个文件作为一个新列读取。我目前有读取和输出到一个新的文件工作,但它输出到一个列的一切,我如何分离出每个文件的数据?
这是我目前拥有的
Import-Csv -Delimiter "`t" -Header @("a","b","c","d","e","f","g","h","i") (Get-ChildItem -path C:Usersxxxxx *.tsv) |
select g |
Export-Csv newfile.csv -NoType
将Get-ChildItem
的输出作为ForEach-Object
的输入,然后分别从每个文件中导入/提取/导出:
Get-ChildItem -path C:Usersxxxxx *.tsv |ForEach-Object {
Import-Csv -LiteralPath $_.FullName -Delimiter "`t" -Header @("a","b","c","d","e","f","g","h","i") |
Select-Object g |
Export-Csv ($_.BaseName + '_newfile.csv') -NoTypeInformation
}