From: Robert Klemme Date: 2011-11-19T04:00:24+09:00 Subject: Re: any command line tools for querying yaml files On Fri, Nov 18, 2011 at 5:17 PM, R. Kumar wrote: > Robert Klemme wrote in post #1032544: >> On Fri, Nov 18, 2011 at 3:58 PM, Dave Baldwin >> wrote: >>>> With yaml, are there any generic tools to query data ? >>> >>> It is just a text file so any of your suggestions (awk/grep/sed/cut) will work. >> >> Why not just read the file in an IRB session and traverse the object >> graph? > Some people store data in multiple yaml files. grep only gets me a > matching line. Not other fields of that file. Even more difficult for > "greater than" or similar queries. What does that have to do with my posting? > I once did a ruby commandline project in which i stored data in a > multi-row format. Great for inserts and if schema changed. But not great > to query. Equally bad for updating. I then changed it to a > delimited/fixed format. Great for query, insert and update, but horrible > when adding columns inside. > Finally, I did another version in sqlite. Again, what does it have to do with what I wrote? > Thus i have apprehensions about using yaml. I'd like to know about > generic tools for fast querying of yml data. YAML stores object graphs - much the same way as an OO database. The speed of querying dramatically depends how the data is laid out. If there is no indexing (think: Hash) then you might need full traversals. Anyway, if the file's contents fit into memory then #select etc. should do pretty good. Maybe you help us by stating what specific kinds of queries you want to do. In the meantime I am still inclined to believe that this can be done pretty slick with IRB and regular Ruby code - maybe with some custom additional methods. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/