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?
*******************************************************
[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