0

我正在尝试从文件中提取一个字段并将提取的字段写入一个新文件,有人可以帮我解决这个问题吗?我在文件中有数据,如下所示

"","Processed","XXXXXX XX XXXX XXXX","Import","hgjgf XXXXXXXXXXX                LTD","XXX","sss,ggg.00","0x/xx/xxxx","Xrrrr XXXXXXXX","","XTH asdf XX XXXXXX
XXX000XXX
XXXXXX XXX OCEAN                                                                                           fsdgdhfjgh","WXXXXX","000XXX","X0ASDFXXX","XX","","","","X","","","X","","",""
4

1 回答 1

1

根据您提供的输入,如果您有一个名为 foo.txt 的文件,则:

Import-CSV C:\Path\To\foo.txt -Header (1..25) | Select-Object '4', '6', '8'

会给你第 4、第 6 和第 8 个字段。您当然可以使用更具描述性的标题,如果文件在第一行中有标题,您可以使用这些标题而无需指定您自己的标题。

于 2012-07-10T20:43:02.340 回答