def generate_tap_s3_csv_to_table_mappings(tap):
    """
    Generating a csv file to table mapping for an s3-csv
    tap. The mapping defines which files needs to be loaded into
    which table and what are the csv characteristics

    Example output that compatible with tap-s3-csv tap:
        "tables": [{
            "table_name": "my_table",
            "search_prefix": "feeds",
            "search_pattern": "export_file_.*.csv",
            "key_properties": ["id"],
            "delimiter": ","
        }]
    """
    s3_csv_tables = []

    # Using the input tap YAML we can generate the
    # required config.json for the tap-s3-csv
    schemas = tap.get('schemas', []) if tap else None
    if schemas:
        # We take the first schema
        tables = schemas[0].get('tables', [])
        for table in tables:
            csv_to_table_mapping = table.get('s3_csv_mapping', {})
            if csv_to_table_mapping:
                csv_to_table_mapping['table_name'] = table['table_name']
                s3_csv_tables.append(csv_to_table_mapping)

    return s3_csv_tables