$: head foo.tsv
148 0.05 49.0530378784848
380 0.8 85.0345986160553
496 0.05 33.665653373865
612 0.15 58.1366745330187
728 0.1 60.8615655373785
844 0.3 69.4102235910563
960 0.2 74.4530218791248
1076 0.2 76.6129354825807
1192 2.25 99.0050397984081
1888 0.5 53.7328506859725
and you've got some field names (field_1,field_2,field_3). Try this:
$: export FIELDS=field_1,field_2,field_3
$: cat foo.tsv| ruby -rjson -ne 'puts ENV["FIELDS"].split(",").zip($_.strip.split("\t")).inject({}){|h,x| h[x[0]]=x[1];h}.to_json'
will give you something that looks like:
{"field_1":"148","field_2":"0.05","field_3":"49.0530378784848"}
{"field_1":"380","field_2":"0.8","field_3":"85.0345986160553"}
{"field_1":"496","field_2":"0.05","field_3":"33.665653373865"}
{"field_1":"612","field_2":"0.15","field_3":"58.1366745330187"}
{"field_1":"728","field_2":"0.1","field_3":"60.8615655373785"}
{"field_1":"844","field_2":"0.3","field_3":"69.4102235910563"}
{"field_1":"960","field_2":"0.2","field_3":"74.4530218791248"}
{"field_1":"1076","field_2":"0.2","field_3":"76.6129354825807"}
{"field_1":"1192","field_2":"2.25","field_3":"99.0050397984081"}
{"field_1":"1888","field_2":"0.5","field_3":"53.7328506859725"}
Hurray.
Ya it worked
ReplyDeleteThank you very much
Great Article
ReplyDeleteJavaScript Training | Javascript Courses
Typescript Training in Chennai | Node.js Training in Chennai | Backbone.JS Training in Chennai | Angularjs Training in Chennai
HTML5 Online Training | JavaScript Training in Chennai
Hurray!!
ReplyDeleteThanks for the snippet
ReplyDeletereally liked your blog. python training in Chennai
ReplyDeletenice blog
ReplyDeletedata science training in bangalore
hadoop training in bangalore
python online training
Thanks for sharing this post, really helpful.
ReplyDeletePython Classes in Chennai
ccna course in Chennai
AWS Training in Chennai
DevOps Training in Chennai
Angularjs Training in Chennai
RPA Training in Chennai
UiPath Training in Chennai
Blue Prism Training in Chennai
Nice post....thanks for sharing useful information..
ReplyDeletePython training in Chennai/
Python training in OMR/
Python training in Velachery/
Python certification training in Chennai/
Python training fees in Chennai/
Python training with placement in Chennai/
Python training in Chennai with Placement/
Python course in Chennai/
Python Certification course in Chennai/
Python online training in Chennai/
Python training in Chennai Quora/
Best Python Training in Chennai/
Best Python training in OMR/
Best Python training in Velachery/
Best Python course in Chennai/
I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
ReplyDeletelinen sarees
silk cotton sarees
dhoti for men
silk shirts for men
designer silk sarees