# Re: add to words syntaxes

**URL:** <https://www.ruby-forum.com/t/re-add-to-words-syntaxes/82502>\
**Category:** Ruby\
**Created:** [March 16, 2006, 10:15am UTC](https://www.ruby-forum.com/t/re-add-to-words-syntaxes/82502 "2006-03-16T10:15:01Z")\
**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 16, 2006, 10:15am UTC](https://www.ruby-forum.com/t/re-add-to-words-syntaxes/82502/1 "2006-03-16T10:15:01Z")

</div>

Thanks, for the answers, but didnt worked. I try to clear my problem,  
Here is the input:

0608A;  
Teszt Kft;  
33445566222;  
;  
20060101;  
20060131;  
0A0001C002A 33445566222  
0A0001C007A Teszt kft

# this text repeat himself with other data several times

This, should look like this:

\<?xml version="1.0" encoding="windows-1250"?\> 0608A Teszt kft # the first line from the txt 33445566222 # second line #thrid line, in this txt is blank 20060101 # fourth 20060131 # fifth 11111111122 # and the lines... Próba Cég .....

So my problem is how can I get an XML source like above. For the columns  
I already have this script:  
outfile = ARGV.shift

lines = ARGF.readlines  
marked\_up\_lines = lines.map do |line|  
words = line.split  
‘’ + words[1] + ‘’ + “\n”  
end

File.open(outfile,‘w’) do |file|  
file.write marked\_up\_lines.join  
end

This works fine, but I dont know what to do with the first 6 lines to  
bring it to look like above and how can I bring ruby to repeat himself  
and what for a character need I to use for repeating…  
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 16, 2006, 10:49am UTC](https://www.ruby-forum.com/t/re-add-to-words-syntaxes/82502/2 "2006-03-16T10:49:11Z")

</div>

Dani wrote:

> 0A0001C007A Teszt kft  
> Teszt kft # the first line from the txt  
> Próba Cég  
> …
> 
> So my problem is how can I get an XML source like above. For the columns  
> I already have this script:  
> outfile = ARGV.shift
> 
> lines = ARGF.readlines

Well, before you start to loop to fill the “mezo” tags, extract the  
other lines:

nyomtatvanyazonosito, nev, adoszam, adoazonosito, tol, ig =  
lines.slice!(0,6).map {|w| w.chomp.chomp(’;’) }  
first\_six\_data = \<\<-EOT

\<?xml ... #{nyomtatvanyazonosito} #{nev} ... EOT ...And then continue processing the array as before. \> marked\_up\_lines = lines.map do |line| \> words = line.split \> '' + words[1] + '' + "\n" \> end \> \> File.open(outfile,'w') do |file| file.write first\_six\_data \> file.write marked\_up\_lines.join \> end HTH (warning: code not tested)
