# Re: add to words syntaxes

**URL:** <https://www.ruby-forum.com/t/re-add-to-words-syntaxes/83116>\
**Category:** Ruby\
**Created:** [March 17, 2006, 12:56pm UTC](https://www.ruby-forum.com/t/re-add-to-words-syntaxes/83116 "2006-03-17T12:56:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dani](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/35a633/32.png) [@dani](https://www.ruby-forum.com/u/dani)\
**Post date:** [March 17, 2006, 12:56pm UTC](https://www.ruby-forum.com/t/re-add-to-words-syntaxes/83116/1 "2006-03-17T12:56:20Z")

</div>

Hi!  
Sorry for me, I’ve puted the lines what you wrote but it can be, that to  
wrong place or something, because I can’t bring it to life. Would you  
please look for it? Ive attach my script…  
Regards:

Daniel

---

<div class="post-metadata">

**Author:** ![dani](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/35a633/32.png) [@dani](https://www.ruby-forum.com/u/dani)\
**Post date:** [March 17, 2006, 3:00pm UTC](https://www.ruby-forum.com/t/re-add-to-words-syntaxes/83116/2 "2006-03-17T15:00:20Z")

</div>

On Fri, 2006-03-17 at 20:54 +0900, Dani wrote:

> Hi!  
> Sorry for me, I’ve puted the lines what you wrote but it can be, that to  
> wrong place or something, because I can’t bring it to life. Would you  
> please look for it? Ive attach my script…

If I had to do this quickly (and without too much thought) I’d do  
something like this:

def process(text\_data, &blk)  
text\_data.split(/^$/m).each do |e|  
dta = e.strip.gsub(/;$/,’’).split(/\n/)  
yield \*(dta.slice!(0…5) + [dta])  
end  
end

Which you’d then use like this:

process(File.read(‘teszt.data’)) do |ny, ne, ados, adoa, to, ig,  
columns|  
puts “#{ny} :: #{ne} :: #{ados} :: #{adoa} :: #{to} :: #{ig}”  
p columns  
end

# =\> 0608A :: Teszt Kft :: 33445566222 :: :: 20060101 :: 20060131

# [“0A0001C002A 33445566222”, “0A0001C007A Teszt kft”]

# 0608M :: Oscar Wild :: 123456789 :: :: 20060101 :: 20060131

# [“0A0001C002A 33445566222”, “0A0001C007A Teszt kft”]

Obviously you’d change the output to suit your needs. Bear in mind I’ve  
not extensively tested this…
