{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import pandas as pd\n",
    "import wget\n",
    "import ssl\n",
    "ssl._create_default_https_context = ssl._create_unverified_context"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "SERVER = \"https://www.perceptualui.org/files/schweigert19_muc/\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if (False):\n",
    "    sorted(data_files)\n",
    "    data_files = [\"DataStudyCollection/%s\" % file for file in os.listdir(\"DataStudyCollection\") if file.endswith(\".csv\") and \"userData\" or \"studyData\" in file]\n",
    "    with open('DataStudyCollection/files.txt', 'w') as filehandle:\n",
    "        for listitem in data_files:\n",
    "            filehandle.write('%s\\n' % listitem)\n",
    "\n",
    "\n",
    "    sorted(data_files)\n",
    "    data_files = [\"DataStudyEvaluation/%s\" % file for file in os.listdir(\"DataStudyEvaluation\") if file.endswith(\".csv\") and \"userData\" or \"studyData\" in file]\n",
    "    with open('DataStudyEvaluation/files.txt', 'w') as filehandle:\n",
    "        for listitem in data_files:\n",
    "            filehandle.write('%s\\n' % listitem)\n",
    "        \n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_csv('DataStudyCollection/files.txt', header=None)\n",
    "df.columns = [\"File\"]\n",
    "df.File = df.File.apply(lambda x: SERVER + x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "for i, e in df.iterrows():\n",
    "    print(e.File)\n",
    "    wget.download(e.File, out=\"DataStudyCollection/\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_csv('DataStudyEvaluation/files.txt', header=None)\n",
    "df.columns = [\"File\"]\n",
    "df.File = df.File.apply(lambda x: SERVER + x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i, e in df.iterrows():\n",
    "    print(e.File)\n",
    "    wget.download(e.File, out=\"DataStudyEvaluation/\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
