Data Reader- Sexual Ecologies
by jude_pinto
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.0.2/papaparse.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.8.0/jszip.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.8.0/xlsx.js"></script>
<script src= "https://cdnjs.com/libraries/xlsx"></script>
<button id="button">Open</button>
<input id="file-input" type="file" name="name" style="display: none;" />
<div id="output" class="foo"></div>
<button id="button2">check</button>
CSS
#input-file-replacer {
padding: 3px 5px;
border: 1px solid #ccc;
border-radius: 3px;
background: #ddd;
color: #333;
cursor: pointer;
}
.wrapper {
margin-right: auto; /* 1 */
margin-left: auto; /* 1 */
max-width: 960px; /* 2 */
padding-right: 10px; /* 3 */
padding-left: 10px; /* 3 */
}
JavaScript
/*
$(document).ready(function(){
var myNamespace = {};
$('#button').on('click', function() {
$('#file-input').trigger('click');
});
document.getElementById('file-input').onchange = function(){
var file = this.files[0];
var reader = new FileReader();
reader.onload = function(progressEvent){
// Testing - Entire file
// console.log(this.result);
var dict = new Object();
var col_total = 62;
var lines = this.result.split(',');
var row_total = Math.round(lines.length / col_total);
var reformat = 1;
var title = col_total;
var ref = 0;
for (var col = 0; col <= row_total; col++ ){
title = title + ref ;
for ( var row = 2; row <= col_total; row++){
let line2 = col_total + reformat;
dict[reformat] = ({"Title" : lines[title], "Value Title" : lines[row], "Value" : lines[line2]});
//console.log(lines[title] + ": " + lines[row] + ", " + lines[line2]);
reformat = reformat+1
ref = 61;
}
}
console.log(dict);
/*
var reformatted = [];
var reformat = 0;
var column_total = 275
var lines = this.result.split(',');
var row_total = Math.round(lines.length / column_total);
for(var row = 3; row <= row_total; row++){
for (var line = 27; line <= column_total; line ++){
let line2 = ((column_total*row) +line- reformat);
//return (lines[line] + ", " + lines[line2]);
document.write(lines[line] + ", " + lines[line2]+", ");
//$('#output').text(lines[line] + ", " + lines[line2]);
//results[row] = lines[line] + ", " + lines[line2];
//Testing
//console.log(line, row, line2);
//console.log(lines[line] + ", " + lines[line2]);
//}
//reformat = reformat + 1;
//}
};
reader.readAsText(file);
};
});
*/
var dict = new Object();
//275 cells
//28-275 area of interest
$(document).ready(function(){
var myNamespace =...