def execute
      File.open(outfile, 'w') do |out|
        out.puts "#{';' unless @key.empty?}#{header_cols.join(';')}"
        files.each do |file|
          @current_key = create_current_key
          @current_source_header = @source_header.shift
          processed_header = false
          File.open(file).each_with_index do |line, index|
            next if line.chomp.empty?

            unless processed_header
              create_file_header unstring(line).split(';')
              processed_header = true
              next
            end

            out.puts create_line unstring(line).split(';')
          end
        end
      end
    end
def execute
      File.open(outfile, 'w') do |out|
        out.puts "#{';' unless @key.empty?}#{header_cols.join(';')}"
        files.each do |file|
          @current_key = create_current_key
          @current_source_header = @source_header.shift
          processed_header = false
          File.open(file).each_with_index do |line, index|
            next if line.chomp.empty?

            unless processed_header
              create_file_header unstring(line).split(';')
              processed_header = true
              next
            end

            out.puts create_line unstring(line).split(';')
          end
        end
      end
    end
Merge files based on common header columns

 :call-seq:
   Sycsvpro::Merger.new(outfile:       "out.csv",
                        files:         "file1.csv,file2.csv,filen.csv",
                        header:        "2010,2011,2012,2013,2014",
                        source_header: "(\\d{4}/),(/\\d{4}/)",
                        key:           "0,0").execute

 Semantics
 =========
 Merges the files file1.csv, file2.csv ... based on the header columns
 2010, 2011, 2012, 2013 and 2014 where columns are identified by the
 regex /(\d{4})/. The first column in a row is column 0 of the file1.csv
 and so on.

 outfile:: result is written to the outfile
 files:: list of files that get merged. In the result file the files are
 inserted in the sequence they are provided
 header:: header of the result file and key for assigning column values
 from source files to result file
 source_header:: pattern for each header of the source file to determine
 the column. The pattern is a regex without the enclosing slashes '/'
 key:: first column value from the source file that is used as first
 column in the target file. The key is optional.
 Merges the files based on the provided parameters