{ "cells": [ { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "from glob import glob\n", "\n", "import os" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "waves = [\n", " wave\n", " for location in os.listdir('data')\n", " for date in os.listdir(os.path.join('data', location))\n", " for wave in os.listdir(os.path.join('data', location, date))\n", "]\n", "assert len(waves) == len(set(waves)), \"Not all filenames are unique :(\"" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "for location in os.listdir('data'):\n", " for date in os.listdir(os.path.join('data', location)):\n", " for wave in os.listdir(os.path.join('data', location, date)):\n", " source = os.path.join('data', location, date, wave)\n", " destination = os.path.join('per_word', wave.split('_')[1])\n", " if not os.path.isdir(destination):\n", " os.mkdir(destination)\n", " os.rename(source, os.path.join(destination, wave))" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "import pandas\n", "\n", "data = pandas.read_csv('/home/herbert/picture-game-result-export.csv', delimiter=';')\n", "data['Filename'] = [x.split('/')[-1] for x in data['Opname']]" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [], "source": [ "for word in os.listdir('per_word'):\n", " for wave in os.listdir(os.path.join('per_word', word)):\n", " source = os.path.join('per_word', word, wave)\n", " if wave not in relevant:\n", " destination = os.path.join('per_word', word, 'irrelevant_accent_' + wave)\n", " os.rename(source, destination)" ] }, { "cell_type": "code", "execution_count": 63, "metadata": {}, "outputs": [], "source": [ "data.to_excel('/home/herbert/picture-game-result-export-filename.xlsx')" ] } ], "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.5.2" } }, "nbformat": 4, "nbformat_minor": 2 }