2009年12月27日日曜日

Ruby on Windows: excel

Ruby on Windows: excel

VB Meets Ruby

VB Meets Ruby

東京工業大学ロボット技術研究会

東京工業大学ロボット技術研究会

Windows における Ruby 開発環境の構築

Windows における Ruby 開発環境の構築

Webアプリから2行でExcelファイルを出力する方法 - bricklife.weblog.*

Webアプリから2行でExcelファイルを出力する方法 - bricklife.weblog.*

Ruby による Win32OLE プログラミング - Excel プログラミング(文書作成編)

Ruby による Win32OLE プログラミング - Excel プログラミング(文書作成編)

Ruby による Win32OLE プログラミング - Excel プログラミング(初級編)

Ruby による Win32OLE プログラミング - Excel プログラミング(初級編)

The Age of the Essay

The Age of the Essay

simoom's nest:"The Age of the Essays"の翻訳

simoom's nest:"The Age of the Essays"の翻訳

2009-12-26 - らいおんの隠れ家 ポール・グレアム「バージョン1.0」

2009-12-26 - らいおんの隠れ家 ポール・グレアム「バージョン1.0」

2009年12月13日日曜日

作りながら学ぶ Ruby入門サポートサイト > Home

作りながら学ぶ Ruby入門サポートサイト > Home

csvファイル ( nn_ClassReadcsv02.rb 使用)

#list.csv
選手No,選手名,県名,学校名,1R,2R,3R,4R
1,選手01,県01,学校01,,,,
2,選手02,県02,学校02,1,1,1,1
3,選手03,県03,学校03,,,,
4,選手04,県04,学校04,,,,
5,選手05,県05,学校05,,,,
6,選手06,県06,学校06,,,,
7,選手07,県07,学校07,,,,
8,選手08,県08,学校08,,,,1
9,選手09,県09,学校09,,,,
10,選手10,県10,学校10,,,,
11,選手11,県11,学校11,,,,
12,選手12,県12,学校12,,,,
13,選手13,県13,学校13,,,,
14,選手14,県14,学校14,,,,
15,選手15,県15,学校15,,,,
16,選手16,県16,学校16
17,選手17,県17,学校17
18,選手18,県18,学校18
19,選手19,県19,学校19
20,選手20,県20,学校20
21,選手21,県21,学校21
22,選手22,県22,学校22
23,選手23,県23,学校23
24,選手24,県24,学校24
25,選手25,県25,学校25
26,選手26,県26,学校26
27,選手27,県27,学校27
28,選手28,県28,学校28
29,選手29,県29,学校29
30,選手30,県30,学校30
31,選手31,県31,学校31
32,選手32,県32,学校32,
33,選手33,県33,学校33,
34,選手34,県34,学校34,
35,選手35,県35,学校35,
36,選手36,県36,学校36,
37,選手37,県37,学校37,
38,選手38,県38,学校38,
39,選手39,県39,学校39,
40,選手40,県40,学校40,
41,選手41,県41,学校41,
42,選手42,県42,学校42,1
43,選手43,県43,学校43,
44,選手44,県44,学校44,
45,選手45,県45,学校45,
46,選手46,県46,学校46,
47,選手47,県47,学校47,
48,選手48,県48,学校48
49,選手49,県49,学校49

#score.csv
順位,選手No,勝ち数,ブックホルツ,バーガー,メディアン,選手の勝数,プログレス
1,46,4.0 ,11.0 ,11.0 ,6.0 ,6.0 ,10.0
1,47,4.0 ,11.0 ,11.0 ,6.0 ,6.0 ,10.0
3,49,4.0 ,10.0 ,10.0 ,5.0 ,6.0 ,10.0
4,43,3.0 ,11.0 ,7.0 ,5.0 ,6.0 ,9.0
4,44,3.0 ,11.0 ,7.0 ,5.0 ,6.0 ,9.0
4,45,3.0 ,11.0 ,7.0 ,5.0 ,6.0 ,9.0
7,40,3.0 ,10.0 ,6.0 ,4.0 ,6.0 ,8.0
7,41,3.0 ,10.0 ,6.0 ,4.0 ,6.0 ,8.0
9,34,3.0 ,9.0 ,5.0 ,4.0 ,6.0 ,7.0
9,35,3.0 ,9.0 ,5.0 ,4.0 ,6.0 ,7.0
9,36,3.0 ,9.0 ,5.0 ,4.0 ,6.0 ,7.0
12,48,3.0 ,8.0 ,6.0 ,4.0 ,6.0 ,7.0
13,37,3.0 ,8.0 ,5.0 ,4.0 ,6.0 ,8.0
13,38,3.0 ,8.0 ,5.0 ,4.0 ,6.0 ,8.0
13,39,3.0 ,8.0 ,5.0 ,4.0 ,6.0 ,8.0
16,42,2.0 ,10.0 ,4.0 ,4.0 ,6.0 ,7.0
17,1,2.0 ,9.0 ,5.0 ,4.0 ,6.0 ,4.0
18,25,2.0 ,9.0 ,3.0 ,5.0 ,6.0 ,6.0
18,29,2.0 ,9.0 ,3.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0.0 ,3.0 ,6.0 ,1.0
47,4,1.0 ,4.0 ,0.0 ,2.0 ,6.0 ,1.0
48,2,0.0 ,5.0 ,0.0 ,2.0 ,6.0 ,0.0
48,3,0.0 ,5.0 ,0.0 ,2.0 ,6.0 ,0.0

#opponents.csv
選手No,1R相手No,2R相手No,3R相手No,4R相手No
1,25,48,26,42
2,26,13,7,4
3,27,14,8,5
4,28,15,9,2
5,29,16,10,3
6,30,17,11,bye
7,31,18,2,16
8,32,19,3,17
9,33,20,4,18
10,34,21,5,19
11,35,22,6,20
12,36,23,bye,21
13,37,2,25,22
14,38,3,27,23
15,39,4,28,24
16,40,5,29,7
17,41,6,30,8
18,42,7,31,9
19,43,8,32,10
20,44,9,33,11
21,45,10,34,12
22,46,11,35,13
23,47,12,36,14
24,48,bye,48,15
25,1,37,13,34
26,2,38,1,35
27,3,39,14,36
28,4,40,15,37
29,5,41,16,38
30,6,42,17,39
31,7,43,18,40
32,8,44,19,41
33,9,45,20,48
34,10,46,21,25
35,11,47,22,26
36,12,49,23,27
37,13,25,43,28
38,14,26,44,29
39,15,27,45,30
40,16,28,46,31
41,17,29,47,32
42,18,30,49,1
43,19,31,37,46
44,20,32,38,47
45,21,33,39,49
46,22,34,40,43
47,23,35,41,44
48,24,1,24,33
49,bye,36,42,45

nn_ClassReadcsv02.rb

class Players
attr_accessor :number, :name, :blg1, :blg2, :score, :opponentnum
def initialize(num)
@number = num
end
end
player = []

require 'csv'

csv = CSV.open('list.csv','r')
csv.each_with_index do |line,n|
#list.csvの1行目をヘッダにすることによって,nを一致させる
player[n] = Players.new(n)
player[n].number = line[0]
player[n].name = line[1]
player[n].blg1 = line[2]
player[n].blg2 = line[3]
end
csv.close
puts

csv = CSV.open('score.csv','r')
csv.each_with_index do |line,n|
pnum = line[1]
player[pnum.to_i].score = line[2]
end
csv.close

csv = CSV.open('opponents.csv','r')
csv.each_with_index do |line,n|
opponents = ''
pnum = line[0]
for i in 1..4 #最大値を取り出したい
opponents << line[i.to_i]
opponents << ':'
end
# player[pnum.to_i].opponentnum = opponents.split(/:/)
player[n].opponentnum = opponents.split(/:/)
end

csv.close

for n in 1..49
print(' 選手No:',player[n].number)
print(' 名前:',player[n].name)
print(' 所属1:',player[n].blg1)
print(' 所属2:',player[n].blg2)
print(' スコア:',player[n].score)
puts
print(' 相手1num:',player[n].opponentnum[0])
print(' 相手2num:',player[n].opponentnum[1])
print(' 相手3num:',player[n].opponentnum[2])
print(' 相手4num:',player[n].opponentnum[3])
puts
end

State of Ruby VMs: Ruby Renaissance - igvita.com

State of Ruby VMs: Ruby Renaissance - igvita.com

Rubyリファレンスマニュアル - Rubyリファレンスマニュアル

Rubyリファレンスマニュアル - Rubyリファレンスマニュアル

Arrayをcar、cdrでまわす - 趣味的にっき

Arrayをcar、cdrでまわす - 趣味的にっき

2009年12月5日土曜日

ruby-excel0_02.xls macro

ruby-excel0_02.xls

Sub SampleRuby01() 'OK
Dim WSH, wExec, sCmd As String, Result As String
Set WSH = CreateObject("WScript.Shell") ''(1)
' sCmd = "ruby d:\nn\!save_NN2\ruby-excel\nn01.rb" ''(2)
sCmd = "ruby d:\\nn\\!save_NN2\\ruby-excel\\nn01.rb" ''(2) ★ディレクトリ区切りは\\
Set wExec = WSH.Exec("%ComSpec% /c " & sCmd) ''(3)
Do While wExec.Status = 0 ''(4)
DoEvents
Loop
Result = wExec.StdOut.ReadAll ''(5)
MsgBox Result
Set wExec = Nothing
Set WSH = Nothing
End Sub

Sub SampleRuby02() 'OK
Dim WSH, wExec, sCmd As String, Result As String
Set WSH = CreateObject("WScript.Shell") ''(1)
sCmd = "ruby d:\\nn\\!save_NN2\\ruby-excel\\nn02.rb" ''(2)★ディレクトリ区切りは\\
Set wExec = WSH.Exec("%ComSpec% /c " & sCmd) ''(3)
Do While wExec.Status = 0 ''(4)
DoEvents
Loop
Result = wExec.StdOut.ReadAll ''(5)
' MsgBox Result '★不要
Set wExec = Nothing
Set WSH = Nothing
End Sub
---------------------------------------------------------------------------
#nn01.rb
#foo = File.open("C:\\nn\\ruby-excel\\foo.txt",'w')
#foo = File.open("D:\\nn\\ruby-excel\\foo.txt",'w')
#D:\nn\!save_NN2\ruby-excel
foo = File.open("D:\\nn\\!save_NN2\\ruby-excel\\漢字ファイル1.txt",'w')
#D:\nn\ruby-excel
foo.puts 'bar'
foo.puts '漢字'
foo.puts '漢字2'
foo.close

#nn02.rb
#foo = File.open("C:\\nn\\ruby-excel\\foo.txt",'w')
#foo = File.open("D:\\nn\\ruby-excel\\foo.txt",'w')
#D:\nn\!save_NN2\ruby-excel
foo = File.open("D:\\nn\\!save_NN2\\ruby-excel\\漢字ファイルfoo-2.txt",'w')
#D:\nn\ruby-excel
foo.puts '漢字1'
foo.puts '漢字2'
foo.puts '漢字3'
foo.close

2009年10月22日木曜日

2009年10月20日火曜日

{Ruby] 配列クラス(4)eachとeach_with_index - Rubyを勉強しようと思ってはじめた日記 - Rubyist

{Ruby] 配列クラス(4)eachとeach_with_index - Rubyを勉強しようと思ってはじめた日記 - Rubyist

csv1処理(みるみるP165)追記A.rb

#追記

require 'csv'
rec1 = ['TEST','test@test.com','this is test.']
rec2 = ['テスト','test@test.jp','これはテストです。']
file = File.open('みるみる追記A.csv','a')
csv2 = CSV::Writer.generate(file)
csv2.add_row(rec1)
csv2.add_row(rec2)

csv2.close

2009年10月18日日曜日

csv1処理C.rb

require 'csv'
csv1 = CSV.open('リストA.csv', 'r')
cs do |Line|
#
end


csv2 = CSV.open('out.csv', 'w')
writer << Line
end

csv1処理B.rb

require 'csv'
CSV.open('リストA.csv', 'r') do |Line|
#
end


CSV.open('out.csv', 'w') do |writer|
writer << Line
end

csv1処理A.rb

require 'csv'
csv1 = CSV.open('リストA.csv','r')
csv1.each_with_index do |Line,n|
#print(n,": ")
#print('No':',Line[1])
#print('name:'Line[2])
#puts
end

No = Line[1]
name = Line[2]

csv2 = CSV.open('exportA.csv','w')
csv2.add_row(Line[1])
csv2.add_row(Line[2])
csv2.add_row(Line[3])
csv2.add_row(Line[4])
csv2.add_row(Line[5])

csv2.close
csv1.close

Rubyを本格的に始めようと思います。ただ、今までVisualStudioやEclipseといった至れり尽くせりな環境で開発を行ってきたので、Rubyでも横着な(楽な)開発を行いたいと考.. - 人力検索はてな

Rubyを本格的に始めようと思います。ただ、今までVisualStudioやEclipseといった至れり尽くせりな環境で開発を行ってきたので、Rubyでも横着な(楽な)開発を行いたいと考.. - 人力検索はてな

Rubyist Magazine - Ruby/SDLで始めるゲームプログラミング【前編】

Rubyist Magazine - Ruby/SDLで始めるゲームプログラミング【前編】

Rubyプログラムの組み方から、Exeファイルの作成まで

Rubyプログラムの組み方から、Exeファイルの作成まで

Placebo Effect :: Rubyで、Windows用アプリケーションを作るには

Placebo Effect :: Rubyで、Windows用アプリケーションを作るには

Ruby で csv をいじる - 只今Ruby勉強中 - Rubyist

Ruby で csv をいじる - 只今Ruby勉強中 - Rubyist

start

ruby recording 1