title = "Raw data gathered 3rd April 2021 - 'shopfronts' in Melksham" note = "Run this file in python3 and you'll get an analysis" note = "S - South Ward; F - Forest Ward; N - North Ward" note = "Natural walking distance in town centre" note = "Multiple business outlets listed once under most appropriate category" note = "Errors and Ommissions Excepted - Graham Ellis" data = ''' * Personal Care Services Dental SSF Optician SSS Hair SSSSSSSSSSSSFFFFF Nails SSSF Tattoo SS Chiropractor S Skin Care S Feet F * Other personal services Fitness SN Gambling SSS Entertainment SNN Political Clubs SFF * Food - ready to eat TakeAway SSSSSSSSSFFFN Restaurant SSSFF Cafe SSSSSSF Pub SSSS Hotel with food S * Goods and supplies General Goods SSS Supermarket SSFN Antiques and Curios SSSFF Flooring SS Jeweller SF Charity Shop SSSSS Butcher SS Chemist SSF Newsagent SF Toys SS Sport equipment S Stationary and services SSF Florist SS Gifts and Accessories SSN Bridal SS Clothes F Kitchen and Appliances FN Bathroom & Tile F Cycles N Fishing Tackle N Lighting N Fish (live) N * Services Recruitment SS Accountant SS Property & Agents SSSSS Town Council S Local Paper S Bank and Building Society SSS Travel Agent SS Insurance SS IT Support SS Post Office S Tourist Information Centre S Care Agency S Funeral Director SSF Solicitor SS Car Services S Library F Pet Grooming F Photography F Cobbler F * Changing and available Vacant SSSSSSFFNN Coming FFFN ''' whatsin = {} wardcount = {} for line in data.splitlines(): fol = line.strip().split('\t') if len(fol) < 2: continue whatsin[fol[0]] = len(fol[-1]) for k in fol[-1]: wardcount[k] = wardcount.get(k,0) + 1 tio = list(whatsin.keys()) tio.sort(key=lambda x:-whatsin[x] * 100 + ord(x[0])) for t in tio: print("{:3d} - {}".format(whatsin[t],t)) print(wardcount)