On 23 Oct 2007, at 09:24, [email protected] wrote:
ok, so it seems that it is not splitting the line into an array. so
what looks to be my array0-6 is actually just array. So, my next
question is how do I split a line by tabs?
I was using array << line.split("\t"), but that isn’t working.
Your split should work. Take care with your Array though. Array#<<
appends the object you give it to an Array. String#split returns an
Array so what you end up with is an Array which contains the Array
generated by split. Perhaps Array#+ is what you need?
irb(main):009:0> array = 
irb(main):010:0> string = “hi\tthere”
=> [“hi”, “there”]
irb(main):012:0> array << string.split("\t")
=> [[“hi”, “there”]]
irb(main):013:0> array += string.split("\t")
=> [[“hi”, “there”], “hi”, “there”]
I am trying to read 1 file then create another file from that 1. My
the output is
| |||| ||
so basically my pipes and spaces are being appended to the end of my
string after the “\n”
Also look up Array#join to make your life easier.