All pastes #295853 Raw Edit

Someone

public ruby v1 · immutable
#295853 ·published 2006-12-29 19:58 UTC
rendered paste body
#!/usr/bin/rubycounter = 0outfile = File.open("UNIVERSE_RUBY.csv","w")IO.foreach("UNIVERSE.csv") do |line|    counter += 1    weight = 0        if (counter == 1)		outfile << line.chop + ",\"weight\"\n"    else    		fields = line.chop.split(',')		vtr_ppp00 = fields[154]		vtr_ppp04 = fields[155]		vtr_pri01 = fields[161]		vtr_pri03 = fields[163]		vtr_pri05 = fields[165]		vtr_pri99 = fields[182]				weight += 0.5 if (vtr_ppp00 == "\"R\"")		weight -= 1   if (vtr_ppp04 == "\"D\"")		weight -= 1   if (vtr_pri01 == "\"D\"")		weight -= 1   if (vtr_pri03 == "\"D\"")		weight -= 1   if (vtr_pri05 == "\"D\"")		weight -= 1   if (vtr_pri99 == "\"D\"")		weight += 1   if (vtr_ppp04 == "\"R\"")		weight += 1   if (vtr_pri01 == "\"R\"")		weight += 1   if (vtr_pri03 == "\"R\"")		weight += 1   if (vtr_pri05 == "\"R\"")		weight += 1   if (vtr_pri99 == "\"R\"")				outfile << line.chop + ",\"" + weight.to_s + "\"\n"	end#	print "Processed: " + counter + "\r"endprint "\n"