I have a csv file for eg
ID,Name,products
101,Tesco,Apple;Banana;Oranges
102,Lidl,Juice;Yogurt
103,Aldi,Fruits;vegetables;rice
Using the pandas library I want to split these into a new csv such that for the products column there is only one value for every field
The following code I've tried only selects those particular column and writes the values to a new csv. I want to modify the output.
df=pd.read_csv('final.csv',delimiter=",", index_col="ID",encoding="ISO-
8859-1")
df1=df[,"Name","Products"]
df1.to_csv('a.csv',header='True')
print (df1)
I want the new csv generated to have the values in the following format-
101,Tesco,Apple
101,Tesco,Banana
101,Tesco,Oranges
102,Lidl,Juice
102,Lidl,Yogurt
103,Aldi,Fruits
..