Delete columns in text files with specific string

六眼飞鱼酱① 提交于 2019-11-29 12:04:48

Using awk:

awk 'NR==1{for (i=1; i<=NF; i++) if ($i ~ /Gtype/) a[i]; 
     else printf "%s%s", $i, OFS; print ""; next}
     {for (i=1; i<=NF; i++) if (!(i in a)) printf "%s%s", $i, OFS; print "" }' file
Log.NE122 Log.NE144
-0.33     1.0
Data Munger

You can also try using the 'data.table' package and assign the columns NULL:

dt <- data.table(df)
dt[, colToDelete := NULL]

"data.table" tries to do most of its operations without having to make copies. The way that you are doing it on data.frames requires a copy to be made.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!