ruby - Reference a subset of a column in a CSV -


After

itemprop = "text">

I want to insert a row-column into a CSV Ruby, and in the subsequent operations, on the sequential lines of a single column Performing a data like

  array [startrow..endrow] [3] .reduce (: +) something like   

I have a CSV file In a specific cell, such as:

  array [somerow] [somecolumn] / 2   

but me ". .. any underlying conversion of the string Only get the "integer" error when I try to reference a subset

Edit: I do the CSV import using the following, which correctly appears to change the number of strings I am:

  array = CSV.read ('spy_very_short.txt',: header = & gt; true, converters: all)   

when I run the suggestion test

  array [somerow] [somecolumn] .class   

I get back "float".

without knowing more about what is returned (I think it always represents a number Is a string), I think you need to convert the string to something you can do with it:

  value = array [somerow] [somecolumn] print value. TELO / 2   

The method returns the best string for an integer on the string class, which you can do for mathematics.

If any figure will be for decimal places, then you probably want instead, it's converted into a boat.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -