-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgroups.py
More file actions
40 lines (31 loc) · 1.24 KB
/
Copy pathgroups.py
File metadata and controls
40 lines (31 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
This script sorts and groups names based on chosen meeting options from a CSV file.
"""
import csv
# Define the filename
FILENAME = "responses.csv"
# Create empty lists for names and chosen meeting options
names = []
chosen_meeting_options = []
# Open the CSV file with explicit encoding
with open(FILENAME, "r", encoding="utf-8") as csvfile:
# Create a CSV reader object
reader = csv.DictReader(csvfile)
# Extract names and chosen meeting options from each row
for row in reader:
names.append(row["Name"])
chosen_meeting_options.append(row["Meeting Days"].split("), "))
# Create a list of dictionaries with names and chosen meeting options
combined_data = []
for index, name in enumerate(names):
combined_data.append(
{"Name": name, "Chosen Meeting Options": chosen_meeting_options[index]}
)
# Print the results
print("Meeting Options:")
# Save the results to a new CSV file named "meeting_options.csv"
with open("meeting_options.csv", "w", newline="", encoding="utf-8") as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=["Name", "Chosen Meeting Options"])
writer.writeheader()
writer.writerows(combined_data)
print("The results have also been saved to a file named 'meeting_options.csv'.")