pianistprogrammer commited on
Commit
5da1d79
·
verified ·
1 Parent(s): 975f3a0

Delete Data_cleaning.ipynb

Browse files
Files changed (1) hide show
  1. Data_cleaning.ipynb +0 -493
Data_cleaning.ipynb DELETED
@@ -1,493 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "d88426e1-fa5b-416a-8af0-e5bfec7450c3",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "# import os\n",
11
- "# import shutil\n",
12
- "\n",
13
- "# def move_audio_files_to_root(gtzan_root_path):\n",
14
- "# \"\"\"\n",
15
- "# Moves all .wav (or .mp3) files from genre subfolders to the root GTZAN folder.\n",
16
- "\n",
17
- "# Args:\n",
18
- "# gtzan_root_path (str): The path to the GTZAN root directory.\n",
19
- "# \"\"\"\n",
20
- "# print(f\"Starting to move audio files from subfolders to: {gtzan_root_path}\")\n",
21
- "\n",
22
- "# if not os.path.isdir(gtzan_root_path):\n",
23
- "# print(f\"Error: The specified path '{gtzan_root_path}' does not exist or is not a directory.\")\n",
24
- "# return\n",
25
- "\n",
26
- "# # Iterate through each item in the GTZAN root directory\n",
27
- "# for item_name in os.listdir(gtzan_root_path):\n",
28
- "# item_path = os.path.join(gtzan_root_path, item_name)\n",
29
- "\n",
30
- "# # Check if it's a directory (assuming genre folders are directories)\n",
31
- "# if os.path.isdir(item_path):\n",
32
- "# genre_folder_path = item_path\n",
33
- "# print(f\"\\nEntering genre folder: {genre_folder_path}\")\n",
34
- "\n",
35
- "# # Iterate through files in the genre folder\n",
36
- "# for file_name in os.listdir(genre_folder_path):\n",
37
- "# file_path = os.path.join(genre_folder_path, file_name)\n",
38
- "\n",
39
- "# # Check if it's a file and has a .wav or .mp3 extension\n",
40
- "# # The user mentioned .wav in the path example and .mp3 in the request.\n",
41
- "# # This script will handle both, prioritizing .wav as per the example.\n",
42
- "# if os.path.isfile(file_path) and (file_name.endswith('.wav') or file_name.endswith('.mp3')):\n",
43
- "# destination_path = os.path.join(gtzan_root_path, file_name)\n",
44
- "\n",
45
- "# # Handle potential file name collisions\n",
46
- "# if os.path.exists(destination_path):\n",
47
- "# print(f\"Warning: File '{file_name}' already exists in the root folder. Skipping move for this file.\")\n",
48
- "# else:\n",
49
- "# try:\n",
50
- "# shutil.move(file_path, destination_path)\n",
51
- "# print(f\"Moved: '{file_path}' -> '{destination_path}'\")\n",
52
- "# except Exception as e:\n",
53
- "# print(f\"Error moving file '{file_name}': {e}\")\n",
54
- " \n",
55
- "# # Optional: Remove the empty genre folder after moving files\n",
56
- "# # This is commented out by default to be safe. Uncomment if desired.\n",
57
- "# # try:\n",
58
- "# # if not os.listdir(genre_folder_path): # Check if folder is empty\n",
59
- "# # os.rmdir(genre_folder_path)\n",
60
- "# # print(f\"Removed empty folder: {genre_folder_path}\")\n",
61
- "# # except OSError as e:\n",
62
- "# # print(f\"Error removing folder {genre_folder_path}: {e}\")\n",
63
- "\n",
64
- "# print(\"\\nScript execution finished.\")\n",
65
- "\n",
66
- "# # --- How to use this script ---\n",
67
- "# # 1. Save this code as a Python file (e.g., move_gtzan_files.py).\n",
68
- "# # 2. Replace 'path/to/your/GTZAN' with the actual path to your GTZAN folder.\n",
69
- "# # Example: If your GTZAN folder is at /Users/YourName/Music/GTZAN,\n",
70
- "# # then set gtzan_folder = '/Users/YourName/Music/GTZAN'\n",
71
- "# # 3. Run the script from your terminal: python move_gtzan_files.py\n",
72
- "\n",
73
- "# # IMPORTANT: Before running, it is highly recommended to back up your GTZAN folder\n",
74
- "# # or test this script on a copy of your data to prevent accidental data loss.\n",
75
- "\n",
76
- "# # Set the path to your GTZAN root folder here:\n",
77
- "# # For example:\n",
78
- "# # gtzan_folder_path = \"/Users/youruser/Documents/GTZAN\"\n",
79
- "# # Or if it's in the same directory as the script:\n",
80
- "# # gtzan_folder_path = \"GTZAN\"\n",
81
- "\n",
82
- "# # !!! IMPORTANT: Replace 'YOUR_GTZAN_ROOT_PATH_HERE' with the actual path !!!\n",
83
- "# gtzan_folder_path = 'GTZAN' \n",
84
- "\n",
85
- "# # Call the function to move the files\n",
86
- "# move_audio_files_to_root(gtzan_folder_path)\n",
87
- "\n"
88
- ]
89
- },
90
- {
91
- "cell_type": "code",
92
- "execution_count": null,
93
- "id": "02c0a633-987d-41ac-b36f-c275321cf06c",
94
- "metadata": {},
95
- "outputs": [],
96
- "source": [
97
- "# import os\n",
98
- "# import csv\n",
99
- "\n",
100
- "# def check_wav_files_against_csvs(gtzan_root_path, csv_file_paths):\n",
101
- "# \"\"\"\n",
102
- "# Checks which WAV files in the GTZAN root folder are not listed in any of the provided CSV files.\n",
103
- "# Also reports which CSV files a WAV file is found in, if it exists.\n",
104
- "\n",
105
- "# Args:\n",
106
- "# gtzan_root_path (str): The path to the GTZAN root directory where WAV files are expected.\n",
107
- "# csv_file_paths (list): A list of full paths to the CSV files to check against.\n",
108
- "# \"\"\"\n",
109
- "# print(f\"Starting check for WAV files in '{gtzan_root_path}' against {len(csv_file_paths)} CSVs.\")\n",
110
- "\n",
111
- "# # Validate GTZAN root path\n",
112
- "# if not os.path.isdir(gtzan_root_path):\n",
113
- "# print(f\"Error: The specified GTZAN path '{gtzan_root_path}' does not exist or is not a directory.\")\n",
114
- "# return\n",
115
- "\n",
116
- "# # 1. Get all WAV files directly in the GTZAN root folder\n",
117
- "# gtzan_wav_files_found = set()\n",
118
- "# try:\n",
119
- "# # Iterate through items in the specified GTZAN root directory\n",
120
- "# for item_name in os.listdir(gtzan_root_path):\n",
121
- "# item_path = os.path.join(gtzan_root_path, item_name)\n",
122
- "# # Check if it's a file and ends with '.wav'\n",
123
- "# if os.path.isfile(item_path) and item_name.endswith('.wav'):\n",
124
- "# gtzan_wav_files_found.add(item_name) # Add just the filename (basename)\n",
125
- "# except Exception as e:\n",
126
- "# print(f\"Error reading GTZAN directory '{gtzan_root_path}': {e}\")\n",
127
- "# return\n",
128
- "\n",
129
- "# if not gtzan_wav_files_found:\n",
130
- "# print(f\"No .wav files found directly in '{gtzan_root_path}'. Please ensure files are in the root as expected.\")\n",
131
- "# return\n",
132
- "\n",
133
- "# # 2. Process CSVs: Store contents and map WAVs to CSVs\n",
134
- "# # A dictionary to store which CSV files each WAV basename is found in\n",
135
- "# # Format: {wav_basename: [csv_filename1, csv_filename2, ...]}\n",
136
- "# wav_to_csv_map = {}\n",
137
- "# # A combined set of all WAV basenames found across ALL CSVs for quick lookup\n",
138
- "# all_csv_files_combined = set()\n",
139
- "\n",
140
- "# for csv_path in csv_file_paths:\n",
141
- "# csv_base_name = os.path.basename(csv_path) # Get just the filename of the CSV\n",
142
- "\n",
143
- "# print(f\"Processing CSV: {csv_base_name}\")\n",
144
- "\n",
145
- "# # Validate CSV file path\n",
146
- "# if not os.path.isfile(csv_path):\n",
147
- "# print(f\"Warning: CSV file '{csv_path}' not found. Skipping this CSV.\")\n",
148
- "# continue\n",
149
- "\n",
150
- "# try:\n",
151
- "# with open(csv_path, mode='r', newline='', encoding='utf-8') as file:\n",
152
- "# reader = csv.reader(file)\n",
153
- "# header = next(reader, None) # Read the header row\n",
154
- "\n",
155
- "# if header is None:\n",
156
- "# print(f\"Warning: CSV file '{csv_base_name}' is empty or has no header. Skipping.\")\n",
157
- "# continue\n",
158
- "\n",
159
- "# # Find the index of the 'filename' column (case-insensitive for robustness)\n",
160
- "# filename_col_index = -1\n",
161
- "# for i, col_name in enumerate(header):\n",
162
- "# if col_name.strip().lower() == 'filename':\n",
163
- "# filename_col_index = i\n",
164
- "# break\n",
165
- "\n",
166
- "# if filename_col_index == -1:\n",
167
- "# print(f\"Error: 'filename' column not found in '{csv_base_name}'. Skipping this CSV.\")\n",
168
- "# continue\n",
169
- "\n",
170
- "# # Read through each row in the CSV\n",
171
- "# for row in reader:\n",
172
- "# if len(row) > filename_col_index:\n",
173
- "# full_filename_from_csv = row[filename_col_index].strip()\n",
174
- "# # Extract basename: e.g., '/GTZAN/country.00056.wav' -> 'country.00056.wav'\n",
175
- "# wav_basename = os.path.basename(full_filename_from_csv)\n",
176
- " \n",
177
- "# all_csv_files_combined.add(wav_basename) # Add to the combined set\n",
178
- "\n",
179
- "# # Update the map indicating which CSV this WAV file is in\n",
180
- "# if wav_basename not in wav_to_csv_map:\n",
181
- "# wav_to_csv_map[wav_basename] = []\n",
182
- "# if csv_base_name not in wav_to_csv_map[wav_basename]: # Avoid duplicate CSV entries for a WAV file\n",
183
- "# wav_to_csv_map[wav_basename].append(csv_base_name)\n",
184
- "\n",
185
- "# except Exception as e:\n",
186
- "# print(f\"Error reading CSV file '{csv_path}': {e}\")\n",
187
- "# continue\n",
188
- "\n",
189
- "# # 3. Cross-reference and report results\n",
190
- "# print(\"\\n--- Consistency Check Results ---\")\n",
191
- "\n",
192
- "# files_not_in_any_csv = [] # List to hold WAV files found in GTZAN but missing from all CSVs\n",
193
- "\n",
194
- "# # Iterate through all WAV files found in the GTZAN folder\n",
195
- "# for wav_file_basename in sorted(list(gtzan_wav_files_found)): # Sort for consistent output\n",
196
- "# if wav_file_basename not in all_csv_files_combined:\n",
197
- "# # If the WAV file is not in our combined set of all CSV filenames\n",
198
- "# files_not_in_any_csv.append(wav_file_basename)\n",
199
- " \n",
200
- "# # Report files that are NOT in any CSV\n",
201
- "# if files_not_in_any_csv:\n",
202
- "# print(\"\\n--- WAV files found in GTZAN folder but NOT listed in any CSV file: ---\")\n",
203
- "# for f in files_not_in_any_csv:\n",
204
- "# print(f\"- {f}\")\n",
205
- "# print(len(files_not_in_any_csv))\n",
206
- "# else:\n",
207
- "# print(\"\\nAll WAV files found in the GTZAN folder are listed in at least one CSV file.\")\n",
208
- " \n",
209
- "\n",
210
- "# print(\"\\nScript execution finished.\")\n",
211
- "\n",
212
- "\n",
213
- "# # --- How to use this script ---\n",
214
- "# # 1. Save this code as a Python file (e.g., check_gtzan_data.py).\n",
215
- "# # 2. Replace 'YOUR_GTZAN_ROOT_PATH_HERE' with the actual path to your GTZAN folder.\n",
216
- "# # 3. Replace 'YOUR_CSV_FOLDER_PATH_HERE' with the actual path to the folder containing your CSV files.\n",
217
- "# # If your CSVs are in the same directory as this script, you can use '.' for csv_folder_path.\n",
218
- "# # 4. Ensure the list 'csv_filenames' matches the exact names of your CSV files.\n",
219
- "# # 5. Uncomment the last line to run the function.\n",
220
- "# # 6. Run the script from your terminal: python check_gtzan_data.py\n",
221
- "\n",
222
- "# # Set the path to your GTZAN root folder here:\n",
223
- "# # Example: gtzan_folder_path = \"/Users/youruser/Documents/GTZAN\"\n",
224
- "# gtzan_folder_path = 'GTZAN'\n",
225
- "\n",
226
- "# # Set the path to the folder containing your CSV files.\n",
227
- "# # Example: csv_folder_path = \"/Users/youruser/Documents/MyData\"\n",
228
- "# # Or if CSVs are in the same directory as the script: csv_folder_path = \".\"\n",
229
- "# csv_folder_path = '.'\n",
230
- "\n",
231
- "# # List of your CSV file names\n",
232
- "# csv_filenames = [\n",
233
- "# 'data_test_4_classes.csv',\n",
234
- "# 'data_test_2_classes.csv',\n",
235
- "# 'data_train_4_classes.csv',\n",
236
- "# 'data_train_2_classes.csv',\n",
237
- "# 'data_val_4_classes.csv',\n",
238
- "# 'data_val_2_classes.csv',\n",
239
- "# ]\n",
240
- "\n",
241
- "# # Create full paths for the CSV files\n",
242
- "# csv_file_paths = [os.path.join(csv_folder_path, f_name) for f_name in csv_filenames]\n",
243
- "\n",
244
- "# # Call the function to check the files\n",
245
- "# # Uncomment the line below to execute the script:\n",
246
- "# check_wav_files_against_csvs(gtzan_folder_path, csv_file_paths)\n",
247
- "\n"
248
- ]
249
- },
250
- {
251
- "cell_type": "code",
252
- "execution_count": null,
253
- "id": "9053eb78-c757-4f7b-ad0e-85d306955ddd",
254
- "metadata": {},
255
- "outputs": [],
256
- "source": [
257
- "# import os\n",
258
- "# import csv\n",
259
- "\n",
260
- "# def check_data_integrity(root_data_path, csv_folder_path, target_csv_filenames, audio_folders):\n",
261
- "# \"\"\"\n",
262
- "# Performs data integrity checks on audio files and CSV entries.\n",
263
- "\n",
264
- "# Checks include:\n",
265
- "# 1. Total file count from specific CSVs.\n",
266
- "# 2. Duplicate WAV files within specified audio folders.\n",
267
- "# 3. Duplicate filenames within specified CSV files.\n",
268
- "# 4. Presence of CSV-listed files in their respective folders.\n",
269
- "\n",
270
- "# Args:\n",
271
- "# root_data_path (str): The parent directory containing audio folders (e.g., GTZAN, MAG).\n",
272
- "# csv_folder_path (str): The path to the directory containing the CSV files.\n",
273
- "# target_csv_filenames (list): A list of CSV filenames to check for total count and content.\n",
274
- "# audio_folders (list): A list of audio folder names (e.g., ['GTZAN', 'MAG', 'OWN', 'FMA']).\n",
275
- "# \"\"\"\n",
276
- "# print(f\"--- Starting Data Integrity Check ---\")\n",
277
- "# print(f\"Root data path: {root_data_path}\")\n",
278
- "# print(f\"CSV folder path: {csv_folder_path}\")\n",
279
- "# print(f\"Target CSVs: {', '.join(target_csv_filenames)}\")\n",
280
- "# print(f\"Audio folders to check: {', '.join(audio_folders)}\\n\")\n",
281
- "\n",
282
- "# # --- 1. Check for duplicate WAV files within audio folders ---\n",
283
- "# print(\"--- Checking for duplicate WAV files within audio folders ---\")\n",
284
- "# folder_wav_files = {} # Stores {folder_name: set_of_wav_basenames}\n",
285
- " \n",
286
- "# for folder_name in audio_folders:\n",
287
- "# folder_path = os.path.join(root_data_path, folder_name)\n",
288
- "# if not os.path.isdir(folder_path):\n",
289
- "# print(f\" Warning: Audio folder '{folder_path}' not found. Skipping duplicate check for this folder.\")\n",
290
- "# continue\n",
291
- " \n",
292
- "# current_folder_files = []\n",
293
- "# duplicates_in_folder = set()\n",
294
- "# seen_files = set()\n",
295
- "\n",
296
- "# for file_name in os.listdir(folder_path):\n",
297
- "# if file_name.lower().endswith(\".wav\"): # Case-insensitive check for .wav\n",
298
- "# if file_name in seen_files:\n",
299
- "# duplicates_in_folder.add(file_name)\n",
300
- "# else:\n",
301
- "# seen_files.add(file_name)\n",
302
- "# current_folder_files.append(file_name) # Store for later path lookup\n",
303
- "\n",
304
- "# folder_wav_files[folder_name] = set(current_folder_files) # Store unique basenames for cross-ref\n",
305
- "\n",
306
- "# if duplicates_in_folder:\n",
307
- "# print(f\" Duplicate WAV files found in '{folder_name}':\")\n",
308
- "# for dup_file in sorted(list(duplicates_in_folder)):\n",
309
- "# print(f\" - {dup_file}\")\n",
310
- "# else:\n",
311
- "# print(f\" No duplicate WAV files found in '{folder_name}'.\")\n",
312
- "# print(\"-\" * 60 + \"\\n\")\n",
313
- "\n",
314
- "# # --- 2. Check for duplicate filenames in CSVs and total count ---\n",
315
- "# print(\"--- Checking CSVs for duplicate filenames and total count ---\")\n",
316
- "# total_csv_entries = 0\n",
317
- "# csv_file_contents = {} # Stores {csv_filename: [list_of_full_filenames_from_csv]}\n",
318
- "\n",
319
- "# for csv_name in target_csv_filenames:\n",
320
- "# csv_path = os.path.join(csv_folder_path, csv_name)\n",
321
- "# if not os.path.isfile(csv_path):\n",
322
- "# print(f\" Warning: CSV file '{csv_path}' not found. Skipping this CSV.\")\n",
323
- "# continue\n",
324
- "\n",
325
- "# current_csv_filenames = []\n",
326
- "# duplicates_in_csv = set()\n",
327
- "# seen_csv_filenames = set()\n",
328
- "\n",
329
- "# try:\n",
330
- "# with open(csv_path, mode='r', newline='', encoding='utf-8') as file:\n",
331
- "# reader = csv.reader(file)\n",
332
- "# header = next(reader, None) # Read the header row\n",
333
- "\n",
334
- "# if header is None:\n",
335
- "# print(f\" Warning: CSV file '{csv_name}' is empty or has no header. Skipping.\")\n",
336
- "# continue\n",
337
- "\n",
338
- "# filename_col_index = -1\n",
339
- "# for i, col_name in enumerate(header):\n",
340
- "# if col_name.strip().lower() == 'filename':\n",
341
- "# filename_col_index = i\n",
342
- "# break\n",
343
- " \n",
344
- "# if filename_col_index == -1:\n",
345
- "# print(f\" Error: 'filename' column not found in '{csv_name}'. Skipping this CSV.\")\n",
346
- "# continue\n",
347
- "\n",
348
- "# for row_num, row in enumerate(reader, 2): # Start row_num from 2 for data rows\n",
349
- "# if len(row) > filename_col_index:\n",
350
- "# full_filename_from_csv = row[filename_col_index].strip()\n",
351
- "# if full_filename_from_csv in seen_csv_filenames:\n",
352
- "# duplicates_in_csv.add(full_filename_from_csv)\n",
353
- "# else:\n",
354
- "# seen_csv_filenames.add(full_filename_from_csv)\n",
355
- "# current_csv_filenames.append(full_filename_from_csv)\n",
356
- "# total_csv_entries += 1\n",
357
- "# else:\n",
358
- "# print(f\" Warning: Row {row_num} in '{csv_name}' is malformed (missing filename column).\")\n",
359
- "\n",
360
- "# csv_file_contents[csv_name] = current_csv_filenames\n",
361
- "\n",
362
- "# if duplicates_in_csv:\n",
363
- "# print(f\" Duplicate filenames found in CSV '{csv_name}':\")\n",
364
- "# for dup_entry in sorted(list(duplicates_in_csv)):\n",
365
- "# print(f\" - {dup_entry}\")\n",
366
- "# else:\n",
367
- "# print(f\" No duplicate filenames found in CSV '{csv_name}'.\")\n",
368
- "\n",
369
- "# except Exception as e:\n",
370
- "# print(f\" Error reading CSV file '{csv_path}': {e}\")\n",
371
- " \n",
372
- "# print(f\"\\n Total entries across {', '.join(target_csv_filenames)}: {total_csv_entries}\")\n",
373
- "# if total_csv_entries == 2800:\n",
374
- "# print(\" Total CSV entries match the expected 2800. Great!\")\n",
375
- "# else:\n",
376
- "# print(f\" Warning: Total CSV entries ({total_csv_entries}) do NOT match the expected 2800.\")\n",
377
- "# print(\"-\" * 60 + \"\\n\")\n",
378
- "\n",
379
- "# # --- 3. Check if all files in CSVs are present in folders ---\n",
380
- "# print(\"--- Checking if CSV-listed files are present in their respective folders ---\")\n",
381
- "# all_csv_listed_files = [] # Store all (full_filename, csv_source) for cross-ref\n",
382
- "# for csv_name, filenames in csv_file_contents.items():\n",
383
- "# for filename_entry in filenames:\n",
384
- "# all_csv_listed_files.append((filename_entry, csv_name))\n",
385
- "\n",
386
- "# # Create a lookup for actual files on disk, using full normalized paths\n",
387
- "# existing_audio_files_on_disk = set()\n",
388
- "# for folder_name in audio_folders:\n",
389
- "# folder_path = os.path.join(root_data_path, folder_name)\n",
390
- "# if os.path.isdir(folder_path):\n",
391
- "# for file_name in os.listdir(folder_path):\n",
392
- "# if file_name.lower().endswith(\".wav\"):\n",
393
- "# # Create the expected path string, matching CSV format (e.g., /GTZAN/file.wav)\n",
394
- "# expected_csv_format_path = f\"/{folder_name}/{file_name}\"\n",
395
- "# existing_audio_files_on_disk.add(expected_csv_format_path)\n",
396
- " \n",
397
- "# missing_files_from_csvs = []\n",
398
- "# found_files_count = 0\n",
399
- " \n",
400
- "# for full_csv_filename, source_csv in all_csv_listed_files:\n",
401
- "# # Normalize the CSV filename path to match our disk lookup (e.g., /GTZAN/file.wav)\n",
402
- "# normalized_csv_path = os.path.normpath(full_csv_filename).replace(os.sep, '/') # Use forward slashes\n",
403
- " \n",
404
- "# if normalized_csv_path in existing_audio_files_on_disk:\n",
405
- "# found_files_count += 1\n",
406
- "# # print(f\" Found: {full_csv_filename} (from {source_csv})\") # Uncomment for verbose output\n",
407
- "# else:\n",
408
- "# missing_files_from_csvs.append((full_csv_filename, source_csv))\n",
409
- "\n",
410
- "# if missing_files_from_csvs:\n",
411
- "# print(\"\\n The following files are listed in CSVs but NOT found in their expected audio folders:\")\n",
412
- "# for missing_file, source_csv in sorted(missing_files_from_csvs):\n",
413
- "# print(f\" - {missing_file} (listed in {source_csv})\")\n",
414
- "# else:\n",
415
- "# print(\" All files listed in the target CSVs were found in their respective audio folders.\")\n",
416
- " \n",
417
- "# print(f\"\\n Total files listed in target CSVs: {len(all_csv_listed_files)}\")\n",
418
- "# print(f\" Total CSV-listed files found on disk: {found_files_count}\")\n",
419
- "\n",
420
- "# print(\"\\n--- Data Integrity Check Finished ---\")\n",
421
- "\n",
422
- "\n",
423
- "# # --- How to use this script ---\n",
424
- "# # 1. Save this code as a Python file (e.g., data_checker.py).\n",
425
- "# # 2. **Replace 'YOUR_PARENT_DIRECTORY_PATH_HERE'** with the actual path to the directory\n",
426
- "# # that contains your GTZAN, MAG, OWN, FMA folders. This is the 'root_data_path'.\n",
427
- "# # Example: If your GTZAN, MAG, OWN, FMA are all directly under `/Users/YourName/AudioData/`,\n",
428
- "# # then set `root_data_path = '/Users/YourName/AudioData/'`\n",
429
- "# # 3. **Replace 'YOUR_CSV_FOLDER_PATH_HERE'** with the actual path to the folder\n",
430
- "# # containing your CSV files.\n",
431
- "# # Example: If your CSVs are in `/Users/YourName/MyCSVs/`, set `csv_folder_path = '/Users/YourName/MyCSVs/'`\n",
432
- "# # If CSVs are in the same directory as this script, you can use `csv_folder_path = \".\"`\n",
433
- "# # 4. The `target_csv_filenames` list is pre-filled with the ones you specified.\n",
434
- "# # 5. The `audio_folders_to_check` list is pre-filled.\n",
435
- "# # 6. Uncomment the last line to run the function.\n",
436
- "# # 7. Run the script from your terminal: `python data_checker.py`\n",
437
- "\n",
438
- "# # !!! IMPORTANT: Ensure your GTZAN folder has its WAV files in the root as per your previous script's output.\n",
439
- "\n",
440
- "# # Set the parent directory path here (where GTZAN, MAG, OWN, FMA are located)\n",
441
- "# root_data_path = '.'\n",
442
- "\n",
443
- "# # Set the path to the folder containing your CSV files\n",
444
- "# csv_folder_path = '.'\n",
445
- "\n",
446
- "# # Define the CSV files to check\n",
447
- "# target_csv_filenames = [\n",
448
- "# 'data_test_2_classes.csv',\n",
449
- "# 'data_train_2_classes.csv',\n",
450
- "# 'data_val_2_classes.csv',\n",
451
- "# ]\n",
452
- "\n",
453
- "# # Define the audio data folders to check for presence of files\n",
454
- "# audio_folders_to_check = ['GTZAN', 'MAG', 'OWN', 'FMA']\n",
455
- "\n",
456
- "# # Call the function to perform the integrity checks\n",
457
- "# # Uncomment the line below to execute the script:\n",
458
- "# check_data_integrity(root_data_path, csv_folder_path, target_csv_filenames, audio_folders_to_check)\n",
459
- "# # print(\"\\nTo run the script, uncomment the last line and replace 'YOUR_PARENT_DIRECTORY_PATH_HERE' and 'YOUR_CSV_FOLDER_PATH_HERE' with your actual folder paths.\")\n",
460
- "# # print(\"This script will help you verify the consistency of your dataset.\")\n"
461
- ]
462
- },
463
- {
464
- "cell_type": "code",
465
- "execution_count": null,
466
- "id": "8ed3c1ea-ca8f-4973-9642-9dfd3a6eb1e7",
467
- "metadata": {},
468
- "outputs": [],
469
- "source": []
470
- }
471
- ],
472
- "metadata": {
473
- "kernelspec": {
474
- "display_name": "Python 3 (ipykernel)",
475
- "language": "python",
476
- "name": "python3"
477
- },
478
- "language_info": {
479
- "codemirror_mode": {
480
- "name": "ipython",
481
- "version": 3
482
- },
483
- "file_extension": ".py",
484
- "mimetype": "text/x-python",
485
- "name": "python",
486
- "nbconvert_exporter": "python",
487
- "pygments_lexer": "ipython3",
488
- "version": "3.11.9"
489
- }
490
- },
491
- "nbformat": 4,
492
- "nbformat_minor": 5
493
- }