def append_files(in_file1, character, in_file2, out_file):
    """
    Created on 24 Oct 2014
    Created for use with Wonderware Archestra.
    Takes a file1 and appends file2 contents joined by a character, line for line.
    
    USAGE:
        %prog in_file1.csv %character in_file2.txt
    @author: Roan Fourie
    @mail: roanfourie@gmail.com
    """
    return_data = 0

    write_data = ''

    i = 0
    try:
        with open(in_file1, 'rt') as fi1:
            lines1 = fi1.readlines() # Read all the lines in fi1 as a tuple
        
        with open(in_file2, 'rt') as fi2:
            lines2 = fi2.readlines() # Read all the lines in fi2 as a tuple
                
        with open(out_file, 'at') as fo:
            fo.seek(0,2)
            while i < len(lines1):
                lines1[i] = lines1[i].rstrip('\n')
                #lines1[i] = lines1[i].rstrip('\r')
                fo.write(lines1[i] + character + lines2[i])
                i = i + 1
        print(write_data)
    except __HOLE__:
        print("Error in reading/writing file.")
        return_data = 2
    else:
        print('Operation completed successfully.')
        return_data = 1
    finally:
        fi2.close()
        fi1.close()
        fo.close()
        print("done")
    return return_data
dataset/ETHPy150Open RoanFourie/ArchestrA-Tools/aaTools/aaAppend.py/append_files