def write_metadata_to_file(filename, cs_id, process,
                           units_e, units_sigma, ref='\\N',
                           lhs_a='\\N', lhs_b='\\N',
                           rhs_a='\\N', rhs_b='\\N', threshold='-1', wavelength='-1',
                           lhs_v=-1, rhs_v=-1, lhs_j=-1, rhs_j=-1,
                           background='\\N', lpu='-1', upu='-1'):
    """Given metadata for a cross section data set,
    write the metadata to a file in the correct format for a NEPC database.

    Parameters
    ----------
    filename: str
        Name of the file where values of ``data_array`` should be written.
    cs_id: int
        ``cs_id`` corresponding to the cross section in the database.
    process: str
        The short name corresponding to the electron scattering process in the 
        database.
    units_e: float
        The units, in eV, of the electron energies.
    units_sigma: float
        The units, in :math:`m^2`, of the cross sections.
    ref: str
        The short name for the reference corresponding to the dataset.
    lhs_a: str
        The short name for the lhs_a state for the process.
    lhs_b: str
        The short name for the lhs_b state.
    rhs_a: str
        The short name for the rhs_a state.
    rhs_b: str
        The short name for the rhs_b state.
    threshold: float
        The threshold electron energy for the process.
    wavelength: float
        The wavelength of the photon associated with the process, if applicable.
    lhs_v: int
        The vibrational energy associated with the LHS state, if applicable.
    rhs_v: int
        The vibrational energy associated with the RHS state, if applicable.
    lhs_j: int
        The rotational energy associated with the LHS state, if applicable.
    rhs_j: int
        The rotational energy associated with the RHS state, if applicable.
    background: str
        Background information for the cross section data.
    lpu: float
        Lower percent uncertainty of the cross section data.
    upu: float
        Upper percent uncertainty of the cross section data.

    Returns
    -------
    : int
        The next cs_id to use.

    """
    write_met = open(filename, "x")
    write_met.write(
        "\t".join(
            ('cs_id',
             'process',
             'units_e',
             'units_sigma',
             'ref',
             'lhs_a',
             'lhs_b',
             'rhs_a',
             'rhs_b',
             'threshold',
             'wavelength',
             'lhs_v',
             'rhs_v',
             'lhs_j',
             'rhs_j',
             'background',
             'lpu',
             'upu')) + "\n")
    write_met.write(
        "\t".join(
            (str(cs_id),
             process,
             str(units_e),
             str(units_sigma),
             ref,
             lhs_a,
             lhs_b,
             rhs_a,
             rhs_b,
             str(threshold),
             str(wavelength),
             str(lhs_v),
             str(rhs_v),
             str(lhs_j),
             str(rhs_j),
             background,
             str(lpu),
             str(upu))))
    write_met.close()
    return cs_id + 1