2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

LinuxでCSVの特定の列がNullの行を取り出す

Last updated at Posted at 2017-10-03

catとawkコマンドで実現。

awkの-Fオプションではデリミタを指定(下記はカンマを指定)。
その後は'パターン {アクション}'という形式で、パターンに一致したときにさせたいアクションを記述。
今回は9番目の項目がNULLだったら行全体を出力させる。
awkの$0は行全体を意味する。今回の場合、おそらく$0は省略可能。

cat target.csv | awk -F, '$9==NULL {print $0}' >9col_null_records.csv

これだけでOK。awk非常に便利。

awkはここのサイトがわかりやすそうだった。
https://www.ibm.com/developerworks/jp/linux/library/l-awk1/index.html

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?