Python Forum

Full Version: Finding Duplicate in CSV file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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]
what have you tried?
(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)
(May-13-2020, 08:25 PM)bond009 Wrote: [ -> ][quote='buran' pid='114314' dateline='1589401219']
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)