Write a Python script to identify the most common email domains present in a CSV file.
- User
Write a Python script to identify the most common email domains present in a CSV file.
Assistant
To identify the most common email domains present in a CSV file, you can use the following Python script:
pythonimport csv from collections import Counter # Read the CSV file with open('emails.csv', 'r') as csvfile: reader = csv.DictReader(csvfile) emails = [email.strip() for email in (row['email'] for row in reader)] # Extract domains from emails domains = [email.split('@') for email in emails] # Count the occurrences of each domain domain_counts = Counter(domains) # Get the most common domain most_common_domain = domain_counts.most_common(1) print(f'The most common email domain is: {most_common_domain}')
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.