On Feb 24, 8:58=A0pm, Simon Krahnke <overl... / gmx.li> wrote:
> * lionbarrage <cmakali... / gmail.com> (02:17) schrieb:
>
>
>
> > File 1
> > ALPHA|OMEGA|GAMMA
> > =A0 =A0 =A0 =A0 =A0 1 | =A0 =A0 =A0 =A0 2 | =A0 =A0 =A0 =A0 =A0 3
> > =A0 =A0 =A0 =A0 =A0 4 | =A0 =A0 =A0 =A0 5 | =A0 =A0 =A0 =A0 =A0 6
>
> > File 2
> > EPSILON|GREEK|OMEGA|BETA
> > =A0 =A0 =A0 =A0 =A0 7 | =A0 =A0 =A0 =A0 8 | =A0 =A0 =A0 =A0 =A0 9 | =A0=
 =A0 =A0 =A00
> > =A0 =A0 =A0 =A0 =A012 | =A0 =A0 =A0 =A0 =A0 | =A0 =A0 =A0 =A0 =A013 |
> > =A0 =A0 =A0 =A0 =A010 | =A0 =A0 =A0 =A011 | =A0 =A0 =A0 =A0 =A0 5 | =A0=
 =A0 =A0 15
>
> > End result should be:
>
> > ALPHA|OMEGA|GAMMA|EPSILON|GREEK|BETA
> > =A0 =A0 =A0 =A0 =A0 1 | =A0 =A0 =A0 =A0 2 | =A0 =A0 =A0 =A0 =A0 3 | =A0=
 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0 =A0|
> > =A0 =A0 =A0 =A0 =A0 4 | =A0 =A0 =A0 =A0 5 | =A0 =A0 =A0 =A0 =A0 6 | =A0=
 =A0 =A0 10 | =A0 =A0 =A0 11 | =A0 =A0 15
> > =A0 =A0 =A0 =A0 =A0 =A0 | =A0 =A0 =A0 =A0 9 | =A0 =A0 =A0 =A0 =A0 =A0 |=
 =A0 =A0 =A0 =A07 | =A0 =A0 =A0 =A08 | =A0 =A0 =A00
> > =A0 =A0 =A0 =A0 =A0 =A0 | =A0 =A0 =A0 =A013 | =A0 =A0 =A0 =A0 =A0 =A0 |=
 =A0 =A0 =A0 12 | =A0 =A0 =A0 =A0 =A0|
>
> I hoped I fixed your ASCII art the right way.
>
> In understand that this represents named sets of integers that are to be
> merged. Right?
>
> The natural representation of that would be a hash containing sets.
> There is a set class, but I use arrays here:
>
> require 'pp'
>
> sets =3D Hash.new { | h, k | h[k] =3D [] } # hash that contains a newarra=
y
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0# for every new key
> %w(file1.txt file2).each do | filename |
> =A0 File.open(filename) do | f |
> =A0 =A0 names =3D f.gets.chop.split('|')
> =A0 =A0 f.each do | line |
> =A0 =A0 =A0 =A0names.zip(line.chop.split('|')).each do | name, value |
> =A0 =A0 =A0 =A0 =A0sets[name] << value
> =A0 =A0 =A0 =A0end
> =A0 =A0 end
> =A0 end
> end
>
> pp sets
>
> This code does no tabular printing, treats the "integers" as strings,
> without excluding empty strings and doubles. But that could easily be
> fixed.
>
> Probably I got it all wrong. :-(
>
> mfg, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0simon .... l

Thanks for fixing my art, looked fine in my screen but I guess the
translation was off.

I'm not too familiar with hashes but the code you wrote seems to be
doing it. Thank you so much!!

  How do i refer to a single element within a hash?  Let's say I want
11 for example.  Would I do sets["GREEK"][3]?

THANK YOU!