ows-master/examen dubbels/script.py
bdaneels b021eabdab Refactor and document code; add new files
Refactored `script.py` by adding detailed docstrings and organizing functions. Created `.idea` configuration files and `gotodashboard.js` for `sisa_crawl` project. Added `readme.md` files with usage instructions and context for multiple scripts, and set up `package.json` for `sisa_crawl` dependencies.
2024-11-18 14:03:25 +01:00

25 lines
779 B
Python

import pandas as pd
# Constants
FILE_PATH = 'ps (30).xlsx'
SHEET_NAME = 'ps (30)'
COLUMN_NAME = 'Student-ID'
def find_duplicates(file_path, sheet_name, column_name):
df = pd.read_excel(file_path, sheet_name=sheet_name)
duplicate_ids = df[df.duplicated(subset=[column_name], keep=False)][column_name]
unique_duplicate_ids = duplicate_ids.drop_duplicates()
return unique_duplicate_ids
def main():
unique_duplicate_ids = find_duplicates(FILE_PATH, SHEET_NAME, COLUMN_NAME)
num_duplicates = len(unique_duplicate_ids)
if not unique_duplicate_ids.empty:
print(f"Duplicated {COLUMN_NAME} values (count: {num_duplicates}):")
print(unique_duplicate_ids)
else:
print("No duplicates found.")
if __name__ == "__main__":
main()