Finding Duplicate in CSV file - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Finding Duplicate in CSV file (/thread-26789.html) |
Finding Duplicate in CSV file - bond009 - May-13-2020 I have CSV with entries like below. I want to generate the CSV file which merge the location into rows if the string before the ',' matches like shown in highlighted. driver/travel1/,location1 driver/travel1/,location2 driver/travel1/,location3 driver/travel1/,location4 driver/travel1/,location5 driver/travel2/,location6 driver/travel2/,location7 driver/travel2/,location8 driver/travel2/,location9 driver/travel2/,location10 driver/travel1/,[location1:location2:location3:location4:location5] driver/trave2/,[location6:location7:location8:location9:location10] RE: Finding Duplicate in CSV file - buran - May-13-2020 what have you tried? RE: Finding Duplicate in CSV file - bond009 - May-13-2020 (May-13-2020, 08:20 PM)buran Wrote: what have you tried? I was trying with pandas, but looks like pandas is not supported in version3.8 Merge = df.read_csv('./Sort_output.txt') df = df.groupby('Node').agg({'Child'}) print(df) RE: Finding Duplicate in CSV file - bond009 - May-14-2020 (May-13-2020, 08:25 PM)bond009 Wrote: [quote='buran' pid='114314' dateline='1589401219'] I was trying with pandas, but looks like pandas is not supported in version3.8 Merge = df.read_csv('./Sort_output.txt') df = df.groupby('Node').agg({'Child'}) print(df) |