def METHOD_NAME(targs):
    table_data = json.loads(targs['export_data'])
    table_rows = table_data['rows']
    buff = io.StringIO()
    writer = csv.writer(buff)
    now = datetime.datetime.now()
    time_str = now.strftime('%H:%M (UTC) %m/%d/%y')
    metadata_rows = [
        ["# Collection Name: " + targs['collection_name_export']],
        ["# User E-mail: " + targs['user_email_export']],
        ["# Time/Date: " + time_str]
    ]
    for row in metadata_rows:
        writer.writerow(row)
    for trait in table_rows:
        writer.writerow([trait])
    csv_data = buff.getvalue()
    buff.close()
    if 'collection_name_export' in targs:
        file_name = re.sub('\s+', '_', targs['collection_name_export']) # replace whitespace with underscore
    else:
        file_name = generate_hash_of_string("".join(table_rows))
    return [file_name, csv_data]