gpt4 book ai didi

parsing - 从CSV删除行

转载 作者:行者123 更新时间:2023-12-02 23:47:28 25 4
gpt4 key购买 nike

我有一个带有多个标题的csv文档,例如:

"Date","RQ","PM","SME","Activity","Status code""2/2/12","6886","D_WV","John Smith","Recent","2004"

and a text document that is just a list of status codes, one per line.

I am trying to figure out how to remove all lines from the CSV that contain the status codes from the text file.

So far I have tried using:

$m = gc textfile.txt
Select-String data.csv -Pattern $m -NotMatch

但是,这给我留下了额外的数据,例如
data.csv:1"Date","RQ","PM","SME","Activity","Status code"data.csv:2"2/2/12","6886","D_WV","John Smith","Recent","2004"

I have also tried:

gc data.csv | ? { $_ -notlike $m }

那会使用正确的格式,但是不想删除任何值。任何帮助深表感谢。

最佳答案

选择字符串中的那些matchinfo对象可能令人困惑。
这会满足您的需求吗?

$m = gc textfile.txt
select-string data.csv -pattern $m -notmatch |
select -expand line

关于parsing - 从CSV删除行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15579316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com