Ami*_*mir 1 csv vim awk replace multiple-columns
我无法为我的具体问题找到任何合理的答案;我知道如何处理 vim/sed 的替换搜索,但是我们如何处理 vim 中关于列模式搜索和替换的 csv。即我们的 csv 数据块如下:
automotive_bitcount,1,1,0,1,0,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,0,0,1,0,0
automotive_bitcount,1,0,0,1,0,1,0,1,1,1,0,0,0,0,1,1,1,0,1,0,1,0,0,1,0
automotive_bitcount,2,1,0,0,0,0,1,0,1,0,1,1,0,0,0,0,0,0,1,1,1,1,0,1,0
automotive_bitcount,2,0,0,0,1,1,0,0,1,0,0,0,1,1,1,0,0,0,0,1,1,1,1,0,0
automotive_bitcount,2,1,0,0,0,1,1,0,1,0,1,1,0,0,1,1,1,0,1,1,1,0,1,1,1
Run Code Online (Sandbox Code Playgroud)
它代表标题:
APP_NAME, DATASET, COMPILER FLAGS#1,...,COMPILER FLAG#24
Run Code Online (Sandbox Code Playgroud)
这是搜索和替换的语句;我想用相应的“编译器标志选项”(我把它放在这里)替换列中的那些“1”,所以最后我可以有类似这样的结构,以便将它们传递给编译器:
automotive_bitcount dataset1 -fno-guess-branch-probability -fno-ivopts -fno-tree-loop-optimize -fno-inline-functions -fno-omit-frame-pointer -falign-jumps -fselective-scheduling -fno-tree-pre -fno-move-loop-invariants
Run Code Online (Sandbox Code Playgroud)
仅供记录,24 个编译器标志如下(按顺序排列):
compilerOptionList= "-funsafe-math-optimizations -fno-guess-branch-probability -fno-ivopts -fno-tree-loop-optimize -fno-inline-functions -funroll-all-loops -fno-omit-frame-pointer -falign-jumps -fselective-scheduling -fno-inline-small-functions -fno-tree-pre ftracer -fno-move-loop-invariants -O2 -fno-tree-ter -fprefethch-loop-arrays -max-unrolled-insns -fno-inline-functions-called-once -fno-cprop-registers -finline-functions -fno-schedule -fno-align-functions -fno-tree-dce -fno-merge-constants"
Run Code Online (Sandbox Code Playgroud)
csv.vim - csv 文件的文件类型插件插件有一个作用范围为特定列的替代命令:
:[range]Substitute [column/]pattern/string[/flags]
Run Code Online (Sandbox Code Playgroud)