import csv import json import argparse parser = argparse.ArgumentParser(description='Analyze territory data by category.') parser.add_argument('filename', help='The CSV file to analyze.') args = parser.parse_args() data = [] with open(args.filename, 'r') as f: reader = csv.DictReader(f) for row in reader: data.append(row) category_address_counts = {} for row in data: category = row['CategoryCode'] if 'Address Count' in row and row['Address Count']: address_count = int(row['Address Count']) if category in category_address_counts: category_address_counts[category] += address_count else: category_address_counts[category] = address_count # --- New code for category colors --- unique_categories = sorted(list(category_address_counts.keys())) # A list of 12 distinct colors colors = [ '#e6194b', '#3cb44b', '#ffe119', '#4363d8', '#f58231', '#911eb4', '#46f0f0', '#f032e6', '#bcf60c', '#fabebe', '#008080', '#e6beff' ] category_colors = {} for i, category in enumerate(unique_categories): category_colors[category] = colors[i % len(colors)] with open('category_map.html', 'w') as f: f.write(f''' Category Map
''')