<jupyter_start><jupyter_text>frame.json.keys() = dict_keys(['avg', 'fix', 'lefteye', 'raw', 'righteye', 'state', 'time', 'timestamp'])  connect to eyetribe tracker and save data in push mode<jupyter_code>subject = 'test'

#initialize log file for eye tracking data
logfile = open('E:\\Diamond\\eyetracker\\test.txt', 'w+')
logfile.write('subject ' + subject + '\n')
logfile.close()

#read in stoping instruction, if stop_eyetracker is '0', we keep tracker in push mode(sending data), if its '1', then we close tracker.
stop_eyetracker_file = open('E:\\Diamond\\eyetracker\\stop_eyetracker.txt', 'r')
stop_eyetracker = stop_eyetracker_file.read().strip()
stop_eyetracker_file.close()

if stop_eyetracker == '0':
    #connect tracker
    tracker = EyeTribe()
    tracker.connect()
    tracker.pushmode()

    logfile = open('E:\\Diamond\\eyetracker\\test.txt', 'a+')
    while stop_eyetracker == '0':
        
        #read the frame (eyetracker data for this timestamp)
        frame = tracker.next()

        #write the eyetracker datta (frame) into json format txt file
        logfile.write(json.dumps( frame.json) + '\n') 

        #check if eyetracker should be stopped
        stop_eyetracker_file = open('E:\\Diamond\\eyetracker\\stop_eyetracker.txt', 'r')
        stop_eyetracker = stop_eyetracker_file.read().strip()
        stop_eyetracker_file.close()
      


    logfile.close()

    tracker.close()<jupyter_output>_listener starting
_hbeater starting
_listener ending<jupyter_text>read the logged eyetracker data, for a single timestamp<jupyter_code>logfile1 = open('E:\\Diamond\\eyetracker\\test.txt', 'r')
stop_reading = 0
while stop_reading == 0:
    line = logfile1.readline()

    if line[0] == '{':
        frame_readdict = json.loads(line)
        
        
        if frame_readdict['timestamp'] == '2019-09-28 21:41:15.268':
            stop_reading = 1
    
logfile1.close()
frame_readdict['timestamp'] 
 frame_readdict['time']
 json.loads(line)
    
frame_readdict<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13726461843409316, 'fraction_numerical': 0.013875123885034688, 'mean_word_length': 3.6953488372093024, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '617829', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 712, 'n_tokens_neox': 676, 'n_words': 151, 'path': 'eyetribe_readframes.ipynb', 'repo_name': 's151202/eyetracker', 'size': '2018'}