"mepython" <a / agni.us> schrieb im Newsbeitrag news:1106926484.356041.45310 / c13g2000cwb.googlegroups.com... > I want to process csv file. Here is small program in python and ruby: > > [root@taamportable GMS]# cat x.py > import csv > reader = csv.reader(file('x.csv')) > header = reader.next() > count = 0 > for data in reader: > count += 1 > print count > > > > [root@taamportable GMS]# cat x.rb > require 'csv' > reader = CSV.open('x.csv', 'r') > header = reader.shift > count = 0 > reader.each {|data| > count += 1 > } > p count > > ******************************************************* > Here is processing time: As you can see ruby is way to slow. Is there > anything to do about ruby code? First I'd try to figure whether it's IO that's slow or CSV. Did you test with something like this: File.open('x.csv') do |reader| count = 0 reader.each {|data| count += 1} p count end Does it make a huge difference? Kind regards robert > ******************************************************* > [root@taamportable GMS]# time python x.py > 26907 > > real 0m0.311s > user 0m0.302s > sys 0m0.009s > > > [root@taamportable GMS]# time ruby x.rb > 26907 > > real 1m48.296s > user 1m36.853s > sys 0m11.188s >