Skip to content

Instantly share code, notes, and snippets.

@wenhoujx
Created June 11, 2014 16:53
Show Gist options
  • Save wenhoujx/8869902f79494014ff45 to your computer and use it in GitHub Desktop.
Save wenhoujx/8869902f79494014ff45 to your computer and use it in GitHub Desktop.
remove from csv1 all csv2, and overwrite csv1.
import sys
import pandas as pd
if __name__ == "__main__":
"""
excluding from f1.csv all those names in f2.csv
and write back to f1
"""
f1, f2 = sys.argv[1:]
df1 = pd.read_csv( f1)
df2 = pd.read_csv(f2)
df1 = df1[~df1.name.isin( df2) ]
df1.to_csv( f1, header=True, index=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment