On Feb 24, 8:58 ¨Βν¬ ΣινοΛςαθξλΌοφεςμ®®®ΐηνψ®μιχςοτεΊ > * lionbarrage <cmakali... / gmail.com> (02:17) schrieb: > > > > > File 1 > > ALPHA|OMEGA|GAMMA > > 1 | 2 | 3 > > 4 | 5 | 6 > > > File 2 > > EPSILON|GREEK|OMEGA|BETA > > 7 | 8 | 9 | ¨Β > > 2 | | 3 | > > 0 | 1 | 5 | ¨Β±µ > > > End result should be: > > > ALPHA|OMEGA|GAMMA|EPSILON|GREEK|BETA > > 1 | 2 | 3 | ¨Β ¨Β ¨Β > > 4 | 5 | 6 | ¨Β±° ±± ±µ > > | 9 | |A0 | | > > | 3 | |A0 12 | ¨Β > > 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 = Hash.new { | h, k | h[k] = [] } # hash that contains a newarray > for every new key > %w(file1.txt file2).each do | filename | > File.open(filename) do | f | > names = f.gets.chop.split('|') > f.each do | line | > ¨Βανεσ®ϊιπ¨μιξε®γθοπ®σπμιτ¨§ό§©©®εαγδο ξανεφαμυ> ¨ΒετσΫξανεΌΌ φαμυ> ¨Βξδ > end > 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, ¨Βινοξ ®®®® 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!