import re


def read_sta_file(sta_file):
    """
    Read information from the station file with free format: net,sta,lon,lat,ele,label.
    The label is designed with the purpose to distinguish stations into types.
    """
    cont = []
    with open(sta_file,'r') as f:
        for line in f:
            line = line.rstrip()
            net,sta,_lon,_lat,_ele,label = re.split(" +",line)
            cont.append([net,sta,float(_lon),float(_lat),int(_ele),label])
    f.close()
    if len(cont)==0:
        raise Exception(f"No content in the station file {sta_file}")
    return cont