Dashboard Temp Share Shortlinks Frames API

HTMLify

app.py
Views: 4 | Author: devwajahat
 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
import pandas as pd
import glob

# 1. Grab all CSV files matching the pattern (dataset1.csv, dataset2.csv, etc.)
# If your files are in a specific folder, add the path (e.g., 'folder_name/dataset*.csv')
file_list = glob.glob('dataset*.csv')

# 2. Read all 50-record CSVs and combine them into one 500-record dataset
df_list = [pd.read_csv(file) for file in file_list]
combined_df = pd.concat(df_list, ignore_index=True)

# 3. Keep only unique customer emails (drops duplicate complaints from the same email)
# Note: Replace 'Email' with the exact name of your email column
combined_df = combined_df.drop_duplicates(subset=['Email'], keep='first')

# 4. Assign a brand new ID to every row (1 up to the final row count)
# If there were no duplicate emails, this will go perfectly from 1 to 500
combined_df['New_Customer_ID'] = range(1, len(combined_df) + 1)

# Optional: Drop the old ID column to clean things up
# combined_df = combined_df.drop(columns=['Old_ID_Column'])

# 5. Export the final cleaned dataset to a single CSV
combined_df.to_csv('final_combined_complaints.csv', index=False)
print(f"Successfully saved {len(combined_df)} records to final_combined_complaints.csv")