My problem is to obtain the 'Active' results and transfer it into
another class which already existed. Do i need to convert the data into
ruby or yaml structures first? (since the purpose of my project is to
produce a yaml file). Thanks in advance
When i printed out fields[2], the outputs are nil. This goes for
field[1] and fields[3]. But when i printed out field[0], the outcome is
the same as when i printed out 'fields'. May i know what i did wrong? Im
using the same code as posted by Mr Gray
"1.a,Maximise use of natural lighting,Active,\n"
["1.a,Maximise use of natural lighting,Active,\n"]
nil
"1.b,Turn-off unnecessary lights/equipment,Active,\n"
["1.b,Turn-off unnecessary lights/equipment,Active,\n"]
nil
Thanks for the solution. i change the "|" to "," and it worked. But Im
still confuse, because I thought .csv file (data) are separated by "|"
in the first place. I guess im wrong
10:02:18 ~$ ruby19 x.rb
"1.a | Maximise use of natural lighting | | Active | | | | | | \n"
["1.a", "Maximise use of natural lighting", "", "Active"]
"Active"
"1.b | Turn-off unnecessary lights/equipment | | Active | | | | | | \n"
["1.b", "Turn-off unnecessary lights/equipment", "", "Active"]
"Active"
10:02:19 ~$ cat x.rb
DATA.each do |line|
a = line.split(/\s*\|\s*/)
p line, a, a[3]
end
__END__
1.a | Maximise use of natural lighting | | Active | | | | | |
1.b | Turn-off unnecessary lights/equipment | | Active | | | | | |
10:02:25 ~$
Kind regards
robert
···
On Mon, Jan 24, 2011 at 2:14 AM, Kamarulnizam Rahim <niezam54@hotmail.com> wrote:
When i printed out fields[2], the outputs are nil. This goes for
field[1] and fields[3]. But when i printed out field[0], the outcome is
the same as when i printed out 'fields'. May i know what i did wrong? Im
using the same code as posted by Mr Gray
On Jan 25, 2011, at 3:55 PM, Kamarulnizam Rahim wrote:
Thanks for the solution. i change the "|" to "," and it worked. But Im
still confuse, because I thought .csv file (data) are separated by "|"
in the first place. I guess im wrong