Created
December 25, 2011 17:23
-
-
Save ainame/1519520 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| #実験結果をcsv化するスクリプト | |
| log = Hash.new | |
| Dir.glob("*/log") do |log_path| | |
| key = "N=" + log_path.match(/N_(.*)\/log/).captures[0] | |
| log[key] = Array.new | |
| open(log_path) do |f| | |
| f.read.each_line do |line| | |
| if line =~ /Pred/ | |
| log[key] << line.split[3] | |
| end | |
| end | |
| end | |
| end | |
| open("./learn_log.csv", "w") do |f| | |
| count = 0 | |
| flag = false | |
| data = Array.new | |
| label = "," | |
| log.each do |key,value| | |
| label << key.to_s + "," | |
| end | |
| data << label | |
| begin | |
| flag = false | |
| line = "#{count}," | |
| log.each do |key, array| | |
| if array[count] | |
| line << array[count] + "," | |
| flag = true | |
| else | |
| line << "," | |
| end | |
| end | |
| data << line | |
| count += 1 | |
| end while flag | |
| data.each do |line| | |
| f.puts line | |
| end | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment