// CSVファイル読み込み
function csvToArray(path) {
    var csvData = new Array();
    var data = new XMLHttpRequest();        
    data.open("GET", path, false);
    data.send(null);
    var LF = String.fromCharCode(10);
    var lines = data.responseText.split(LF);
    for (var i = 0; i < lines.length;++i) {
        var cells = lines[i].split(",");
        if( cells.length != 1 ) {
            csvData.push(cells);
        }
    }
    return csvData;
}

var arrayToMap = (function () {
    function mapfn (values) {
        for (var i = 0, l = this.length, obj = Object.create(null); i < l; ++i) {
            if (values.hasOwnProperty(i)) {
                obj[this[i]] = values[i];
            }
        }
        
        return obj;
    }
    
    return function arrayToMap (array, keys) {
        return array.map(mapfn, keys);
    }
}());

var data = csvToArray("audio/music.csv");
var keys = ['name','url','hint','singer','answer']
var fileList = arrayToMap(data, keys);
// 曲リストの連想配列確認用Log
console.log(JSON.stringify(fileList));

console.log(fileList.length)

