Test

       Училище: ТУЕС
#Клас: 11Б
#Номер: 25
#Име: Петър Георгиев Нетовски
#Описание: Проверяваме CSV файл и събираме първите 10 числа и извеждаме сумата в нов CSV файл.
require ‘csv’

def process
        count = 0
        sum = 0.00
        CSV.open(“new.csv”, “w”) do |csv|
                CSV.foreach(“that.csv”) do |row|
                        if count > 10
                                csv << [“sum= “, “#{sum}”]
                                break
                        end
                        sum += #{row[0]}.to_f
                        count+=1
                end
end
end
process

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: