|
3 | 3 | from collections import Counter
|
4 | 4 | from tkinter import Tk, filedialog
|
5 | 5 |
|
6 |
| -# Tkinter kullanarak dosya seçme penceresi açma |
| 6 | +# Use Tkinter to open file dialog for selecting the input file |
7 | 7 | root = Tk()
|
8 |
| -root.withdraw() # Tkinter ana penceresini gizle |
| 8 | +root.withdraw() # Hide Tkinter main window |
9 | 9 | file_path = filedialog.askopenfilename(filetypes=[("Excel files", "*.xlsx *.xls")])
|
10 | 10 |
|
11 | 11 | if file_path:
|
12 |
| - # Excel dosyasını oku |
| 12 | + # Read the selected Excel file |
13 | 13 | df = pd.read_excel(file_path)
|
14 | 14 |
|
15 |
| - # C sütunundaki URL'leri al |
16 |
| - urls = df.iloc[:, 2] # C sütunu üçüncü sütun olduğu için iloc[:, 2] |
| 15 | + # Get the URLs from the third column (C column) |
| 16 | + urls = df.iloc[:, 2] # C column is the third column, so iloc[:, 2] |
17 | 17 |
|
18 |
| - # Alan adlarını çıkar |
| 18 | + # Extract domains from the URLs |
19 | 19 | domains = [urlparse(url).netloc for url in urls if isinstance(url, str)]
|
20 | 20 |
|
21 |
| - # Alan adlarının kaç defa kullanıldığını say |
| 21 | + # Count the occurrences of each domain |
22 | 22 | domain_counts = Counter(domains)
|
23 | 23 |
|
24 |
| - # Sonuçları yeni bir DataFrame'e yaz |
| 24 | + # Write the results to a new DataFrame |
25 | 25 | result_df = pd.DataFrame(list(domain_counts.items()), columns=['Domain', 'Count'])
|
26 | 26 |
|
27 |
| - # Sonuçları yeni bir Excel dosyasına yaz |
| 27 | + # Use file dialog to save the output file |
28 | 28 | output_file_path = filedialog.asksaveasfilename(defaultextension=".xlsx", filetypes=[("Excel files", "*.xlsx *.xls")])
|
29 | 29 | if output_file_path:
|
30 | 30 | result_df.to_excel(output_file_path, index=False)
|
31 |
| - print(f"Sonuçlar {output_file_path} dosyasına kaydedildi.") |
| 31 | + print(f"Results saved to {output_file_path}.") |
32 | 32 | else:
|
33 |
| - print("Çıktı dosyası seçilmedi.") |
| 33 | + print("Output file not selected.") |
34 | 34 | else:
|
35 |
| - print("Dosya seçilmedi.") |
| 35 | + print("Input file not selected.") |
0 commit comments