import re


def colsName(colnames):
    """
    This function obtain the column names with the text before the hyphen in each colnames entry
    
    Parameters: colname is the string from the text before the hyphen is obtained
    Return:     category_colnames is the list with columns names for the message categories
    """
    category_colnames=[] # Stores the messages categories as colunm names

    # select the first row of the categories dataframe
    row = colnames
    #print("row=",row)

    cols=re.split(';',row)
    #print("\n",cols)

    for x in cols:
        col=re.split("-",x)[0] # Get the text before the hyphen
        category_colnames.append(col)

    return category_colnames