Carlos
3/16/2006 3:15:00 PM
Dani wrote:
[...]
> What is if I in my TXT file the parameters repeat self?
> So I mean:
> 0608A;
> Teszt Kft;
> 33445566222;
> ;
> 20060101;
> 20060131;
> 0A0001C002A 33445566222
> 0A0001C007A Teszt kft
>
> 0608M
> Oscar Wild
> 123456789
> ;
> 20060101;
> 20060131;
> 0A0001C002A 33445566222
> 0A0001C007A Teszt kft
>
> etc.. So I need, that on the end of the first paragraph it looks for the
> second. How can I do this? With the same syntax, same file.
> Regards:
# Set the "input record delimiter" to "paragraph". This is
# a special case and you weren't expected to know it beforehand :)
original_delimiter = $/
$/ = ""
# ... read the "lines" (chunks of text between <newline><newline>) ...
chunks = ARGF.readlines
# ... and restore the IRS to <newline>
$/ = original_delimiter
# now extract individual lines from each chunk and process them as before
chunks.each do |chunk|
lines = chunk.split($/)
... < the previous code > ...
end
HTH - (not tested)