title: Trim a trailing .0
body: <p>I have an Excel column containing part numbers. Here is a sample</p>
  
  <p><img src="https://i.stack.imgur.com/1p4z8.png" alt=""></p>
  
  <p>As you can see, it can be many different datatypes: <code>Float</code>, <code>Int</code>, and <code>String</code>. I am using <code>roo</code> gem to read the file. The problem is that <code>roo</code> interprets integer cells as <code>Float</code>, adding a trailing zero to them (16431 => 16431.0). I want to trim this trailing zero. I cannot use <code>to_i</code> because it will trim all the trailing numbers of the cells that require a decimal in them (the first row in the above example) and will cut everything after a string char in the <code>String</code> rows (the last row in the above example).</p>
  
  <p>Currently, I have a a method that checks the last two characters of the cell and trims them if they are ".0"</p>
  
  <pre><code>def trim(row)
      if row[0].to_s[-2..-1] == ".0"
          row[0] = row[0].to_s[0..-3]
      end
  end
  </code></pre>
  
  <p>This works, but it feels terrible and hacky. What is the proper way of getting my Excel file contents into a Ruby data structure?</p>