def parse_step_id_from_sacct(output, step_name):
    """Parse and return the step id from a sacct command

    :param output: output of sacct --noheader -p
                   --format=jobname,jobid --job <alloc>
    :type output: str
    :param step_name: the name of the step to query
    :type step_name: str
    :return: the step_id
    :rtype: str
    """
    step_id = None
    for line in output.split("\n"):
        sacct_string = line.split("|")
        if len(sacct_string) < 2:
            continue
        if sacct_string[0] == step_name:
            step_id = sacct_string[1]
    return step_id