How to sum identical strings and sort them from txt file in python
I have a txt file(named file.txt) that contains two columns(ip-address and bytes, [,,]-separator) file = open(file=’file.txt’) print(file.read()) output: 13.107.4.52,,323 184.51.238.190,,505 184.51.238.190,,505 96.17.7.76,,1066 185.48.81.253,,1061 40.127.240.158,,1443 13.107.42.16,,1544 20.190.160.15,,6342 20.86.249.62,,2700 52.109.12.19,,1435 52.109.12.19,,1435 184.51.238.190,,425 40.127.240.158,,1978 20.73.130.64,,2674 204.79.197.200,,943 204.79.197.200,,943 204.79.197.200,,776 I need to combine lines with duplicate ip-addresses and sum bytes, sorted by bytes. The same thing like excels’s "Consolidate… Read More How to sum identical strings and sort them from txt file in python