|
import csv |
|
from collections import Counter |
|
|
|
|
|
topic_counter = Counter() |
|
include_positive = False |
|
interested_topics = ["none", "error", "issue", "high cpu utilization", "lambdas", "authentication issue", |
|
"error message"] |
|
summary_list = [] |
|
topic_summary_list = {} |
|
|
|
try: |
|
with open('csv/platform-engg-updated.csv', 'r', newline='', encoding='utf-8') as csvfile: |
|
csv_reader = csv.DictReader(csvfile) |
|
|
|
for row in csv_reader: |
|
|
|
positive_topics = eval(row['Positive Topics']) |
|
negative_topics = eval(row['Negative Topics']) |
|
|
|
|
|
|
|
if include_positive: |
|
for topic in positive_topics: |
|
topic_counter[topic.lower()] += 1 |
|
|
|
for topic in negative_topics: |
|
topic_counter[topic.lower()] += 1 |
|
if topic.lower() in interested_topics: |
|
summary_list.append(row['Summary']) |
|
if topic.lower() in topic_summary_list: |
|
topic_summary_list[topic.lower()].append(row['Summary']) |
|
else: |
|
topic_summary_list[topic.lower()] = [row['Summary']] |
|
|
|
|
|
print(f"Consolidated List of Topics with Frequency({len(topic_counter.items())}):") |
|
for topic, freq in topic_counter.most_common(): |
|
print(f"{topic}, {freq}") |
|
print("Short listed summaries:") |
|
for topic in topic_summary_list: |
|
print(f"-------------------{topic}-------------------------------" ) |
|
for summary in topic_summary_list[topic]: |
|
print(summary) |
|
print(" ") |
|
except FileNotFoundError: |
|
print("File not found. Please make sure the file 'your_file.csv' exists in the same directory as this script.") |
|
except Exception as e: |
|
print(f"An error occurred: {e}") |
|
|