Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #7282
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: Is there a way to insert table rows into an array? |
| Date | 2016-07-27 12:51 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <nnaao2$8fl$1@dont-email.me> (permalink) |
| References | <0f796612-2d59-4b70-832d-8214ac73ad81@googlegroups.com> |
Troy wrote:
> I have a table with a few rows like the below
>
> No. Name Emp id
> 1 John 123383
> 2 Bob 389736
> 3 Danny 932303
> 4 Joy 832652
>
> Is there a way to insert the table rows into an array
> in Ruby which should look like:
>
> ArrTable= ["1","John","123383"
> "2","Bob","389736"
> "3","Danny","932303"
> "4","Joy","832652" ]
>
s = "
No. Name Emp id
1 John 123383
2 Bob 389736
3 Danny 932303
4 Joy 832652"
s.strip.lines.drop(1).map(&:split)
==>[["1", "John", "123383"], ["2", "Bob", "389736"], ["3", "Danny",
"932303"], ["4", "Joy", "832652"]]
require 'pp'
==>true
pp s.strip.lines.drop(1).map(&:split)
[["1", "John", "123383"],
["2", "Bob", "389736"],
["3", "Danny", "932303"],
["4", "Joy", "832652"]]
--
Amazon bans book. After nearly a month on the site, all traces of the book and
its 80 reviews have been removed.
http://jamesfetzer.blogspot.com/2015/11/debunking-sandy-hook-debunkers-5.html
https://www.youtube.com/watch?v=EEl_1HWFRfo
Back to comp.lang.ruby | Previous | Next — Previous in thread | Find similar | Unroll thread
Is there a way to insert table rows into an array? Troy <remyamv@gmail.com> - 2016-07-26 03:07 -0700 Re: Is there a way to insert table rows into an array? "WJ" <w_a_x_man@yahoo.com> - 2016-07-27 12:51 +0000
csiph-web