{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import glob\n",
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "os.chdir('..')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'c:\\\\Git_Repos\\\\ml-services'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "files = glob.glob('*/*.tsv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "files += glob.glob('*/data/*.tsv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Sentiment analysis on amazon alexa reviews\\\\amazon_alexa.tsv',\n",
       " 'Classification of amazon reviews\\\\data\\\\amazon_reviews_us_Luggage_v1_00.tsv',\n",
       " 'Classification of amazon reviews\\\\data\\\\amazon_reviews_us_Watches_v1_00.tsv']"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Prediction of IOT system failures based on sensor data PM_test.txt\n",
      "c:\\Git_Repos\\ml-services\\Prediction of IOT system failures based on sensor data\n",
      "Prediction of IOT system failures based on sensor data PM_train.txt\n",
      "c:\\Git_Repos\\ml-services\\Prediction of IOT system failures based on sensor data\n",
      "Prediction of IOT system failures based on sensor data PM_truth.txt\n",
      "c:\\Git_Repos\\ml-services\\Prediction of IOT system failures based on sensor data\n"
     ]
    }
   ],
   "source": [
    "for datafile in files:\n",
    "    foldername, filename = datafile.split('\\\\')\n",
    "    print(foldername, filename)\n",
    "    os.chdir(foldername)\n",
    "    print(os.getcwd())\n",
    "    foldername = foldername.replace(' ', '_')\n",
    "    new_name = foldername + '_' + filename\n",
    "    os.rename(filename, new_name)\n",
    "    \n",
    "    os.chdir('..')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# terminal command to upload all csv files\n",
    "# gsutil -m cp */*.csv gs://ml-service-repository-datastorage  \n",
    "# gsutil -m cp */*.tsv gs://ml-service-repository-datastorage  \n",
    "# gsutil -m cp */*.txt gs://ml-service-repository-datastorage  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# make the bucket public\n",
    "# gsutil iam ch allUsers:objectViewer gs://ml-service-repository-datastorage"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "d8ad938b111551bd971540a987a9651c3040c84fd74b784460cb61a1a48b653c"
  },
  "kernelspec": {
   "display_name": "Python 3.8.9 64-bit ('venv': venv)",
   "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.8.9"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}