0

if ステートメントの結果を csv 内の新しい列として追加する簡単な例を探して、スタック オーバーフローを調べてきました。

以下の例のデータでは、列 3 (0 ベースの参照) の単語テーブルの存在に基づいて 6 番目の列を作成したいと思い"table exists"ます。"No table found"

サンプルデータ:

title1,title2,title3,Table or no table?,title4
data,text,data,the cat sits on the table,text,data
data,text,data,tables are made of wood,text,data
data,text,data,the cat sits on the television,text,data
data,text,data,the dog chewed the table leg,text,data
data,text,data,random string of words,text,data
data,text,data,table seats 25 people,text,data
data,text,data,I have no idea why I made this example about tables,text,data
data,text,data,,text,data

望ましい出力:

title1,title2,title3,Table or no table?,title4,Table exists?
data,text,data,the cat sits on the table,text,data,table exists
data,text,data,tables are made of wood,text,data,table exists
data,text,data,the cat sits on the television,text,data,No table found
data,text,data,the dog chewed the table leg,text,data,table exists
data,text,data,random string of words,text,data,No table found
data,text,data,table seats 25 people,text,data,table exists
data,text,data,I have no idea why I made this example about tables,text,data,table exists
data,text,data,,text,data,No table found

これはおそらく非常に単純な作業かもしれませんが、私は現在非常に初心者であり、このタイプのコードは現在私の Python レパートリーにはありません。何かお役に立てば幸いです、ありがとう GTPE

4

1 に答える 1