的Bash shell脚本 - CSV解析 [英] Bash shell scripting - csv parsing

查看:303
本文介绍了的Bash shell脚本 - CSV解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图解析包含潜在的100K +线CSV。这里是我的标准有:

I am trying to parse a CSV containing potentially 100k+ lines. Here is the criteria I have:


  1. 标识符的指数结果

  2. 的标识值

我想找回在CSV是有特定指数(用逗号分隔)给定值的所有行。

I would like to retrieve all lines in the CSV that have the given value in the given index (delimited by commas).

任何想法,同时在特别考虑性能?

Any ideas, taking in special consideration for performance?

推荐答案

使用,第一架原型机老式的grep 削减

First prototype using plain old grep and cut:

grep ${VALUE} inputfile.csv | cut -d, -f${INDEX}

如果这是速度不够快,并给出正确的输出,你就大功告成了。 :)

If that's fast enough and gives the proper output, you're done. :)

这篇关于的Bash shell脚本 - CSV解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆