def detect_file_format(data):
    """ Determine format of a file

    Parameters
    ----------
    data : string
        string containing file data.

    Returns
    -------
    format : string
        File format. 'excellon' or 'rs274x' or 'unknown'
    """
    lines = data.split('\n')
    for line in lines:
        if 'M48' in line:
            return 'excellon'
        elif '%FS' in line:
            return 'rs274x'
        elif len(line.split()) >= 2 and line.split()[0] == 'P' and line.split(
            )[1] == 'JOB':
            return 'ipc_d_356'
    return 'unknown'
