'Function to merge multiple translated csv files into one
and then merge/overwrite the existing w2p language file'

def write_w2p(self, csvfiles, lang_code, option):

    w2pfilename = os.path.join(current.request.folder, 'languages', ('%s.py' % lang_code))
    data = {}
    errors = 0
    for f in csvfiles:
        newdata = self.read_csv(f)
        cols = len(newdata[0])
        if (cols == 1):
            raise SyntaxError('CSV    file    needs    to    have    at    least    2    columns!')
        elif (cols == 2):
            for row in newdata:
                data[row[0]] = row[1]
        else:
            for row in newdata:
                data[row[1]] = row[2]
    if (option == 'm'):
        keys = data.keys()
        olddata = read_dict(w2pfilename)
        for s in olddata:
            if (s not in keys):
                data[s] = olddata[s]
    write_dict(w2pfilename, data)
