Edward Edward - 2 years ago 118
Ruby Question

Replacing dot with comma in Ruby spreadsheet

I'm trying to replace the dots with commas in the entire Price-column.

enter image description here

This doesn't work.

#replace dots with commas in price column
@price_column = sheet.column(15)
@price_column.each do |c|

What am I doing wrong?

Answer Source

The issue is that you are using to_f on a string having invalid format for a float. The ruby to_f only take the digits before , and returns the float. You should not be worried about converting the string into float.

The correct code will be:

@price_column = sheet.column(15)
@price_column.each do |c|
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download