#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""A script that parses raw data output by jsPASAT (jsPsych), compiles each
participant's data and creates/updates a file in jsPASAT's ``data``
directory.
"""
import os
import glob

import pandas as pd


PROJECT_DIR = os.path.abspath(os.path.join(__file__, '..', '..'))
DATA_DIR = os.path.join(PROJECT_DIR, 'data')


def get_csv_paths(basedir, exp_stage):
    """Take base data directory and experiment stage. Return list of file paths.
    """
    glob_path = os.path.join(basedir, exp_stage, '*.csv')
    return glob.glob(glob_path)


def compile_practice_data(data):
    pass


def main():
    raw_data = {
        'paths': {}
    }

    for exp_stage in ['practice', 'experiment', 'follow_up']:
        raw_data['paths'][exp_stage] = get_csv_paths(DATA_DIR, exp_stage)

    compiled_data = []
    for csv_path in raw_data['paths']['practice']:
        participant = {}

        practice_data = pd.DataFrame.from_csv(csv_path)
        compiled_practice_data = compile_practice_data(practice_data)
        participant.update()


if __name__ == '__main__':
    main()

@@ -676,16 +676,69 @@
 %0A    %7D%0A%0A
+    # TODO: %22SubjectID.%22, %22OutliersAndMissingdata%22,%0A%0A
     for 
@@ -1122,16 +1122,972 @@
 date()%0A%0A
+    # TODO: %22BlockLength%22, %22Anticipated_Enjoyment%22, %22Anticipated_Performance%22, %22Anticipated_Effort%22, %22Anticipated_Fatigue%22, %22Max_Effort%22, %22Min_Effort%22, %22First_Effort%22, %22Last_Effort%22, %22Average_Effort%22, %22AUC_Effort%22, %22Hard_Effort%22, %22Medium_Effort%22, %22Easy_Effort%22, %22Max_Discomfort%22, %22Min_Discomfort%22, %22First_Discomfort%22, %22Last_Discomfort%22, %22Average_Discomfort%22, %22AUC_Discomfort%22, %22Hard_Discomfort%22, %22Medium_Discomfort%22, %22Easy_Discomfort%22,%0A    # %22Max_Accuracy%22, %22Min_Accuracy%22, %22First_Accuracy%22, %22Last_Accuracy%22, %22Average_Accuracy%22, %22AUC_Accuracy%22, %22Hard_Accuracy%22, %22Medium_Accuracy%22, %22Easy_Accuracy%22,%0A    # %22PWMT_Effort%22, %22PWMT_Discomfort%22, %22PWMT_Enjoyment%22, %22PWMT_Performance%22, %22PWMT_fatigue%22, %22PWMT_satisfaction%22, %22PWMT_WillingToDoWMT%22, %22PWMT_BeContacted%22,%0A    # %22Sex%22, %22Age%22, %22edu_year%22, %22edu_plan%22, %22first_lang%22, %22years_eng%22, %22moth_edu%22, %22moth_job%22, %22fath_edu%22, %22fath_job%22, %22uni_major%22, %22ethnicity%22, %22ethnicity_TEXT%22, %22born%22, %22motherborn%22, %22fatherborn%22,%0A%0A
 %0Aif __na

Add TODOs