Ejemplo n.º 1
0
    """

    for t in xrange(len(data2)):
        start_time3 = time.time()
        batchInsert = []
        batchInsert.append("BEGIN BATCH")
        # print 'at time: ',t
        for z in xrange(len(data2[0][0][0])):
            for y in xrange(len(data2[0][0])):
                for x in xrange(len(data2[0])):
                    # print 999
                    # the data for subject is in data[i][x][y][z][time]
                    # print str(x),str(y),str(z),str(t)
                    tempInsert = prepareInsert(
                        "engagement",
                        fileName[:-4] + "total2",
                        [subject, x, y, z, t, data2[t][x][y][z]],
                        tableColumns=" (subject,x,y,z,time,data) ",
                    )

                    # print tempInsert;
                    batchInsert.append(tempInsert)
                    # dont forget to comment this line out when in actual enviornment
                    # sys.exit(0)
                    """                  
                    if(len(batchInsert)>10):
                        batchInsert.append(' APPLY BATCH;')
                        sys.exit(0)
                    """
                    # session.execute(tempInsert)
                    # print 'inserting: '+ tempInsert
        batchInsert.append(" APPLY BATCH;")
Ejemplo n.º 2
0
 46 --> X, from left to right.
 274 --> time, from lower time to higher time
 '''    
 
 for t in xrange(len(data[0][0][0][0])):
     start_time3 = time.time();
     batchInsert=[]
     batchInsert.append('BEGIN BATCH')
     print 'at time: ',t
     for z in xrange(len(data[0])):
         for y in xrange(len(data[0][0])):
             for x in xrange(len(data[0][0][0])):
                 #print 999
                 #the data for subject is in data[i][x][y][z][time]
                 #print str(x),str(y),str(z),str(t)
                 tempInsert = prepareInsert('engagement',fileName[:-4]+'t'+str(subject),[x,y,z,t,data[subject][z][y][x][t]],tableColumns = ' (x,y,z,time,data) ')                    
                              
                 #print tempInsert;
                 batchInsert.append(tempInsert)
                 '''                    
                 if(len(batchInsert)>10):
                     batchInsert.append(' APPLY BATCH;')
                     sys.exit(0)
                 '''
                 #session.execute(tempInsert)
                 #print 'inserting: '+ tempInsert 
     batchInsert.append(' APPLY BATCH;')
     temp = ' '.join(batchInsert)
     tryInsert(session,temp,1)
   #  session.execute(temp)
     print("--- run time for t: %s seconds ---" % str(time.time() - start_time3))
Ejemplo n.º 3
0
    22 subjects for hitchcockdatao

    '''   
    
    for t in xrange(len(data2)):
        start_time3 = time.time();
        batchInsert=[]
        batchInsert.append('BEGIN BATCH')
       #print 'at time: ',t
        for z in xrange(len(data2[0][0][0])):
            for y in xrange(len(data2[0][0])):
                for x in xrange(len(data2[0])):
                    #print 999
                    #the data for subject is in data[i][x][y][z][time]
                    #print str(x),str(y),str(z),str(t)
                    tempInsert = prepareInsert('engagement',fileName[:-4]+'total',[subject,x,y,z,t,data2[t][x][y][z]],tableColumns = ' (subject,x,y,z,time,data) ')                    
                                 
                    #print tempInsert;
                    batchInsert.append(tempInsert)
                    #dont forget to comment this line out when in actual enviornment                    
                    #sys.exit(0)
                    '''                  
                    if(len(batchInsert)>10):
                        batchInsert.append(' APPLY BATCH;')
                        sys.exit(0)
                    '''
                    #session.execute(tempInsert)
                    #print 'inserting: '+ tempInsert 
        batchInsert.append(' APPLY BATCH;')
        temp = ' '.join(batchInsert)
        #sys.exit(0)