From: "Peña, Botp" Date: 2007-08-29T17:37:44+09:00 Subject: Re: Help parsing simple structured data. From: Nuby Ruby [mailto:nubyruby@gmail.com] # of processing is the bit of code I use most in my daily life, and the # hardest for me to wrap my head around when I play with new langauges. you sound like an admin or you do admin tasks daily. just want to tell you that there's a gem called ruport used for reporting task. ..just in case it may help you. this is just a simple example. i snipped the initial echos fr irb. the last outputs will give you an idea... so, >require 'rubygems' >require 'ruport' >data =`df -h`.split "\n" >header=data.shift.split " ",6 >data = data.map{|line| line.split} >report = Ruport::Data::Table.new :data => data, :column_names => header >puts report +-------------------------------------------------------------------------------+ | Filesystem | Size | Used | Avail | Use% | Mounted on | +-------------------------------------------------------------------------------+ | /dev/hda1 | 3.8G | 3.1G | 566M | 85% | / | | varrun | 125M | 68K | 125M | 1% | /var/run | | varlock | 125M | 4.0K | 125M | 1% | /var/lock | | udev | 125M | 76K | 125M | 1% | /dev | | devshm | 125M | 0 | 125M | 0% | /dev/shm | | lrm | 125M | 18M | 107M | 15% | /lib/modules/2.6.15-28-686/volatile | | /dev/hdb1 | 19G | 6.9G | 13G | 36% | /disk2 | | /dev/hdd1 | 2.0G | 731M | 1.3G | 37% | /disk3-1 | | /dev/hdd2 | 2.1G | 65M | 1.9G | 4% | /disk3-2 | +-------------------------------------------------------------------------------+ => nil > puts report.column("Filesystem") /dev/hda1 varrun varlock udev devshm lrm /dev/hdb1 /dev/hdd1 /dev/hdd2 => nil > puts report.column("Size") 3.8G 125M 125M 125M 125M 125M 19G 2.0G 2.1G => nil there are a lot of fxns in ruport that allow you to sum on columns, swap them, remove/add columns, drill down on records, etc... many thanks to GBrown and MMilner, et al for ruport. kind regards -botp