使用bash中的列条件删除CSV文件中的行

时间:2015-01-20 20:38:58

标签: r bash csv awk sed

我有一个很大的CSV文件(5Go)。标题是:

run number,export,downerQ,coefUpQuality,chooseMode,demandF,nbPLots,standarDevPop,nbCitys,whatWord,priceMaxWineF,marketColor,[step],giniIndexReserve,giniIndexPatch,meanQualityTotal,meanQualityMountain,meanQualityPlain,DiffExtCentral,nbcentralPlots,meanPatchByNetwork,sum_q_viti_moutain,sum_q_viti_plaine
"3","false","0.5","0.01","false","7000","10","2","10","0","70","false","0","0","0.07083333333333335","0","0","0","0","0","0","48","0"
"4","false","0.5","0.01","false","7000","10","2","10","0","70","false","0","0","0.04285714285714286","0","0","0","0","0","0","42","0"
"2","false","0.5","0.01","false","7000","10","2","10","0","70","false","0","0","0.05348837209302328","0","0","0","0","0","0","43","0"

我想只保留包含" 500"在现场[步骤](第十三场)。

  • 我尝试在sqlite中导入此CSV ...但删除崩溃...
  • R也崩溃了(即使是来自data.table的fread)

是否有人使用sedawk或任何其他命令等工具获得解决方案?

1 个答案:

答案 0 :(得分:4)

awk似乎要走了:

awk -F, 'NR == 1 || $13 == "\"500\""' filename

NR == 1保留第一行(标题)的位置,之后只有第13个字段为"500"的行。