{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6b8d5520",
   "metadata": {},
   "source": [
    "# Combine Split ZIP Files\n",
    "\n",
    "- Set `folder` to the directory containing your split files. \n",
    "- Replace the example filenames in `parts` with your filenames, in the correct order. \n",
    "- Ensure Part 1 and Part 2 are downloaded and saved in the same folder for 25.6 kHz sampling rate\n",
    "- Ensure Part 1, Part 2 and Part 3 downloaded and saved in the same folder for 51.2 kHz sampling rate\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6c0a21df",
   "metadata": {},
   "source": [
    "# For files with 25.6 kHz"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d1b19ca7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Combined ZIP file created: C:\\Users\\05394\\Desktop\\ss\\6314_25.6_kHz_Dataset_combined.zip\n"
     ]
    }
   ],
   "source": [
    "from pathlib import Path\n",
    "\n",
    "folder = Path(r\"D:\\path\\to\\your\\folder\") # Replace with the actual path to your folder containing the parts\n",
    "\n",
    "part1 = folder / \"6314 25.6 kHz Dataset Part 1 of 2\"\n",
    "part2 = folder / \"6314 25.6 kHz Dataset Part 2 of 2\"\n",
    "joined_file = folder / \"6314_25.6_kHz_Dataset_combined.zip\"\n",
    "\n",
    "for part in (part1, part2):\n",
    "    if not part.exists():\n",
    "        raise FileNotFoundError(f\"File not found: {part}\")\n",
    "\n",
    "# Join the two parts in order\n",
    "with joined_file.open(\"wb\") as output:\n",
    "    for part in (part1, part2):\n",
    "        with part.open(\"rb\") as source:\n",
    "            output.write(source.read())\n",
    "\n",
    "print(f\"Combined ZIP file created: {joined_file}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "836d7272",
   "metadata": {},
   "source": [
    "# For files with 51.2 kHz"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "89628e29",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Combined ZIP file created: C:\\Users\\05394\\Desktop\\ss\\51_Hz\\6314_51.2_kHz_Dataset_combined.zip\n"
     ]
    }
   ],
   "source": [
    "from pathlib import Path\n",
    "\n",
    "folder = Path(r\"D:\\path\\to\\your\\folder\") # Replace with the actual path to your folder containing the parts\n",
    "\n",
    "part1 = folder / \"6314 51.2 kHz Dataset Part 1 of 3\"\n",
    "part2 = folder / \"6314 51.2 kHz Dataset Part 2 of 3\"\n",
    "part3 = folder / \"6314 51.2 kHz Dataset Part 3 of 3\"\n",
    "joined_file = folder / \"6314_51.2_kHz_Dataset_combined.zip\"\n",
    "\n",
    "for part in (part1, part2, part3):\n",
    "    if not part.exists():\n",
    "        raise FileNotFoundError(f\"File not found: {part}\")\n",
    "\n",
    "# Join the three parts in order\n",
    "with joined_file.open(\"wb\") as output:\n",
    "    for part in (part1, part2, part3):\n",
    "        with part.open(\"rb\") as source:\n",
    "            output.write(source.read())\n",
    "\n",
    "print(f\"Combined ZIP file created: {joined_file}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6cd6ce72",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
