Performing problems

23 views
Skip to first unread message

dinamita

unread,
Feb 4, 2011, 9:58:56 AM2/4/11
to ruby-roo
I am getting unacceptable performace problems by using the roo gem for
reading a file by using XLSX or XLS library from this gem.

Someone may suggest me an alternative about how to parse an .XLSX
file?

<CODE>
parsed_file = Excel.new(filename,false, :ignore) if
(file_format.upcase
== "XLS")
parsed_file = Excelx.new(filename,false, :ignore) if
(file_format.upcase == "XLSX")
raise t "#{filename} is not an Excel file!" if (!parsed_file)

parsed_file.default_sheet =
parsed_file.sheets[0]#'Sheet2'#oo.sheets[1]

first_row = parsed_file.first_row
last_row = parsed_file.last_row
first_column = parsed_file.first_column
last_column = parsed_file.last_column
#logger.info "#### Total Rows:#{last_row},
first_row:#{first_row},
last_row:#{last_row}, first_column:#{first_column},
last_column:#{last_column}"

first_row.upto(last_row) do |current_line|
# Stuff ....
end
</CODE>

The mongrel servers hangs for .xls or .xlsx from files of 3767 rows
such as:

002N6V3 1506 RH-128 YE YEMEN MOBILE BLACK 0,5 KILOGRAMS Y Y

002N6V3 1506 RH-128 YE YEMEN MOBILE BLACK 0,5 KILOGRAMS Y Y

........

But it worked well for 1000 rows and less.

By the console it worked. but after around 34 mins. Unacceptable in
webs. By using Spreadsheet takes acceptable time and not hangs
mongrels server. Supposedly is more moder roo gem than Spreadsheet.

I used it also as the next way:

<CODE>
parsed_file = Excelx.new(filename,false, :ignore) if
(file_format.upcase == "XLSX")
(1..parsed_file.last_row).each { |row|
ret << parsed_file.row(row)
}
</CODE>

Someone is experiencing the same problems with this gem? Any
alternatives apart from running this task in background later by using
delayed_jobs?


Many thanks in advance
Reply all
Reply to author
Forward
0 new messages