I'm new to Python and trying to do the following. I have a csv file like below, (input.csv)
a,v,s,f
china,usa,china and uk,france
india,australia,usa,uk
japan,south africa,japan,new zealand
where I'd like to remove duplicates with respect to each row to get the below.
a,v,s,f (output.csv)
china,usa, and uk,france
india,australia,usa,uk
japan,south africa,,new zealand
Notice that though 'usa' is repeated in two different rows, it still is kept intact, unlike 'china' and 'japan', which are repeated in same rows.
I tried doing using OrderedDict from collections in the following way
from collections import OrderedDict
out = open ("output.csv","w")
items = open("input.csv").readlines()
print >> out, list(OrderedDict.fromkeys(items))
but it moved all the data into one single row