import os.path

def targs_rm(indx):

    """
    Reads the targets.csv file, deletes all of the lines identified in the
    index array indx (presumably generated by a "where" statement), and
    writes the result back out to targets.csv

    Run this first to set path if needed:
    import os.path
    os.environ["NRESROOT"] = "/Users/rolfsmei/Documents/research/nres_4/nres_copy4/"

    """

    import pandas as pd

    nresroot=os.getenv("NRESROOT")

    targfile = nresroot+'reduced/csv/targets.csv'

    #Read in targfile
    df = pd.read_csv(targfile)

    #Dropping Filenames matching lines in indx
    df_out = df[~df['Targname'].isin(indx)]

    #Writing out file
    df_out.to_csv(targfile,index=False)