Input file format (three columns, tabs delimited):
A \t X1, X2 \t Z1, Z2
B \t X3 \t Z3
C \t X4, X5, X6 \t Z4, Z5, Z6
Expected file format:
A X1 Z1
A X2 Z2
B X3 Z3
C X4 Z4
C X5 Z5
C X6 Z6
My code:
a = Array.new()
x = Array.new()
z = Array.new()
s = String.new()
open("c:\\temp\\a.txt").each {|e|
a = e.split("\t")
x = a[1].split(",")
z = a[2].split(",")
x.each_index {|i|
s = a[0] +"\t" + x[i] +" \t" + z[i]
puts s
}
}
On Thu, May 1, 2008 at 11:07 PM, Adam Masiarek <adam@masiarek.com> wrote:
Input file format (three columns, tabs delimited):
A \t X1, X2 \t Z1, Z2
B \t X3 \t Z3
C \t X4, X5, X6 \t Z4, Z5, Z6
Expected file format:
A X1 Z1
A X2 Z2
B X3 Z3
C X4 Z4
C X5 Z5
C X6 Z6
My code:
a = Array.new()
x = Array.new()
z = Array.new()
s = String.new()
open("c:\\temp\\a.txt").each {|e|
a = e.split("\t")
x = a[1].split(",")
z = a[2].split(",")
x.each_index {|i|
s = a[0] +"\t" + x[i] +" \t" + z[i]
puts s
}
}
On May 1, 4:07 pm, Adam Masiarek <a...@masiarek.com> wrote:
Input file format (three columns, tabs delimited):
A \t X1, X2 \t Z1, Z2
B \t X3 \t Z3
C \t X4, X5, X6 \t Z4, Z5, Z6
Expected file format:
A X1 Z1
A X2 Z2
B X3 Z3
C X4 Z4
C X5 Z5
C X6 Z6
My code:
a = Array.new()
x = Array.new()
z = Array.new()
s = String.new()
open("c:\\temp\\a.txt").each {|e|
a = e.split("\t")
x = a[1].split(",")
z = a[2].split(",")
x.each_index {|i|
s = a[0] +"\t" + x[i] +" \t" + z[i]
puts s
}