Published unlisted
Edited
Apr 3, 2022
Insert cell
Insert cell
Insert cell
Insert cell
meta_participants = FileAttachment('metadata_participants.txt').tsv({typed: true})
Insert cell
Insert cell
participants = _.filter(meta_participants, d=> {
return ((d.ERROR_RATE < 0.5) && (d.ECPC <= 0.05) && (d.AVG_WPM_15 >55) )})
Insert cell
Inputs.table(participants)
Insert cell
Insert cell
Insert cell
Insert cell
ALL_KEYS = ['PARTICIPANT_ID','AGE','GENDER','HAS_TAKEN_TYPING_COURSE','COUNTRY','LAYOUT','NATIVE_LANGUAGE','FINGERS','TIME_SPENT_TYPING','KEYBOARD_TYPE','ERROR_RATE','AVG_WPM_15','AVG_IKI','ECPC','KSPC','ROR']
Insert cell
function refact(keystrokes) {

let UniqueSentances = _.uniqBy(keystrokes.map( d=>{
return {TEST_ID:d.TEST_SECTION_ID, SENTENCE:d.SENTENCE, USER_INPUT:d.USER_INPUT,}
}),'SENTENCE')


let teTests = []
for (let sent of UniqueSentances) {

let TH = _.filter(keystrokes,{TEST_SECTION_ID:sent.TEST_ID})

let startTime = TH[0].PRESS_TIME
sent.TYPED = TH.map( d=> {
return {
// ksID: d.KEYSTROKE_ID, // don't really need this one
pTIME: d.PRESS_TIME-startTime,
rTIME: d.RELEASE_TIME-startTime,
// CHAR: d.LETTER, // not all files contain the letter but KEYCODE is valid
kCODE: d.KEYCODE}
})
teTests.push(sent)
}

let participant={}
participant.PARTICIPANT_ID = keystrokes[0].PARTICIPANT_ID
participant.tests = teTests
return participant
}
Insert cell
Insert cell
viewof keyStrokesZIP_file = Inputs.file({label: 'Load in file keystrokes.zip',accept: ".zip" , required: true})
Insert cell
zfile = keyStrokesZIP_file.zip()
Insert cell
zipNames = zfile.filenames
Insert cell
keystrokeFiles = participants.map( d =>{
return `Keystrokes/files/${d.PARTICIPANT_ID}_keystrokes.txt`
})
Insert cell
Insert cell
FilesProcessed = {
let f = await FileAttachment("ddl.txt").text()
f = _.split(f,",")
return _.sortBy(f.map(d=>+d))
}
Insert cell
The code below only downloaded 6937 files of the 20628 files.


I need to make a list of files that have been processed and then only process the files not done.

Added a sleep to not overload the OS

# TODO

The meta data needs to also be filtered to remove junk data (ie hours per day spent typing has many that a +18 and +24 hours)

add a button to enable saving, so it doesn't try and make files on it's own.

currently the save is commented out.
Insert cell
ks = {

for (const file of keystrokeFiles) {

let filename = `${_.trim(file,'Keystrokes/files/txt')}json`
let fileNumber = _.trim(filename,'_keystrokes.json')

const found = FilesProcessed.find(d => d == fileNumber); // temp test file
if(found == undefined ) {
// let blooby = serialize(refact(await zfile.file(file).tsv( {typed: true})))
// FileSaver.saveAs(blooby, filename);
await sleep(200) // have a sleep so OS doesnt get over loaded
}
}
return
}
Insert cell
sleep = ms => new Promise(r => setTimeout(r, ms));
Insert cell
# TODO: more data filtering.

Some of the files contain a NULL character code. It looks like the person entering the data has stopped or there session was cut off.
I am guessing there is around a 100-200 files of the 20628 that could have this problem.

Insert cell
Insert cell
FileSaver = require('https://bundle.run/file-saver@2.0.5') // I can auto save files.
Insert cell
import {serialize} from '@palewire/saving-json'
Insert cell
import {ASCII_TABLE} from "@hellonearthis/ascii-table"
Insert cell
Insert cell
keystrokes32 = FileAttachment('32_keystrokes.txt').tsv( {typed: true})
Insert cell
<style>
.katex-display,p,ul,h1,h2,h3,h4,li
{
font-family: sans-serif;
}

@media (hover: hover) {
.katex-display,p,ul,h1,h2,h3,h4,li {
max-width: ${width}px;
min-width: ${width}px; }
}
</style>
Insert cell
Insert cell
FileAttachment('readme.txt').text()
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more