-
Notifications
You must be signed in to change notification settings - Fork 0
/
ticket_filter.py
34 lines (26 loc) · 1.2 KB
/
ticket_filter.py
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
import pandas as pd
def process_excel_file(input_file, output_file):
# Read the Excel file
df = pd.read_excel(input_file)
# Keep only the necessary columns
columns_to_keep = ['Incident ID', 'Summary', 'Resolution', 'Status']
df = df[columns_to_keep]
# Filter rows to keep only the ones with 'Resolved' status
df = df[df['Status'] == 'Resolved']
# Remove rows where 'Resolution' has unwanted values (case insensitive)
unwanted_solutions = ['.', '...', 'fixed', 'resolved', 'test', 'duplicate', 'other']
df = df[~df['Resolution'].str.strip().str.lower().isin(unwanted_solutions)]
# Drop the 'Status' column since it's no longer needed
df = df.drop(columns=['Status'])
# Rename the columns
df = df.rename(columns={
'Incident ID': 'Ticket #',
'Summary': 'Problem',
'Resolution': 'Solution'
})
# Export the result to a CSV file
df.to_csv(output_file, index=False)
# Example usage
input_file = 'MIR Exports2024_17_10_18_41_21.xlsx' # replace with your input Excel file path
output_file = 'tickets_dataset_NEW.csv' # replace with your desired output CSV file path
process_excel_file(input_file, output_file)