Created
April 25, 2013 15:00
-
-
Save masukomi/5460367 to your computer and use it in GitHub Desktop.
a simple shell script to expose a bug in the spreadsheet gem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# it expects you're going to pass it the spreadsheet found here | |
# http://masukomi.org/misc/spreadsheet_float_test.xls | |
raise "Needs a path argument" unless ARGV[0] | |
require 'spreadsheet' | |
file_path = ARGV[0] | |
Spreadsheet.client_encoding = 'UTF-8' | |
book = Spreadsheet.open(StringIO.new(File.read(file_path))) | |
sheet = book.worksheets.first | |
row_num = 1 | |
sheet.each 1 do |row| | |
puts "row #{row_num} column 0: #{row[0]} & is_a #{row[0].class.name}" | |
row_num += 1 | |
end | |
@zdavatz & is_a #{row[0].class.name}"
this part of code is just an example to show as it is coming as Float instead String.
He wants to get the value from row[0] as it was in the source spreadsheet, a string, and not write the last part of the message to String.
Yeah @Marinofull
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How about:
{row[0].to_s.class.name}